Basics

Sunday, 3 April 2016

SIMPLE LINE FOLLOWER ROBOT

Hello guys in this tutorial lets see how to make an simple line follower robot with single infra-red sensor. 

Usually for beginners in Robotics this is your first robot to play with Since this robot has some basic functions and basic programming learning this is like learning the A,B,C,D.... of Robotics.

  A line follower is an autonomous Robot which is able to follow a line (black or white) and alter its path based on the shape of the line.


COMPONENTS NEEDED:

  • Arduino UNO
  • one IR-sensor module
  • L293D motor driver
  • metal chassis
  • 2x BO motors
  • 1x caster wheel
  • 2x wheels
  • 2x 9v battery
  • 2x dc battery connectors
  • connecting wires
   The chassis is the body of this Robot, Arduino is the brain of this robot and two dc motors produce motion.


HOW IT WORKS?!


This is a simplest bot with a single sensor so its working principle is also as simple as follows..

  1.    when the IR sensor sees the black line one wheel of the bot rotates and the bot turns away from the line.
  2.   when the IR sensors sees the white background the other wheel rotates and the bot turns slightly towards the line.

           The above two steps occurs one after other in a repeat mode very fastly in a very short time which gives us the movement of the bot in the path following the black line.

    It just follows the Z pattern turning towards the line and turning away from the line.

LETS MAKE THE ROBOT:


STEP 1:

 Fix the wheels on the metal chassis and mount the Dc BO motors on the back wheels and fix a caster wheel in the front.
connect the L293D motor driver with the arduino and dc motors.

CONNECTIONS:

3,6(l293d) to left motor(output)
11,14(l293d) to right motor(output)

2,7,10,15(l293d) to pins 10,11,5,6 of Arduino(inputs)
Note: if the robot doesn't turn in the particular side of curves properly swap the motor pins connections and try it out.

STEP 2:


Connect your Arduino to your IR sensor.

  1. connect out pin of IR to pin 2 of Arduino
  2. connect vcc of IR to 5v of Arduino
  3. connect gnd of IR to gnd pin of Arduino.

STEP 3:

The programming part....

 Interface your arduino with arduino IDE software and upload the below program.





int lmotorpin1=5;

int lmotorpin2=6;
int rmotorpin1=10;
int rmotorpin2=11;
int sensor=2;
int sensorstate=0;

void setup(){
  pinMode(sensor,INPUT);
  pinMode(lmotorpin1,OUTPUT);
  pinMode(lmotorpin2,OUTPUT);
  pinMode(rmotorpin1,OUTPUT);
  pinMode(rmotorpin2,OUTPUT);
}

void loop(){
  sensorstate=digitalRead(sensor);
  if(sensorstate==HIGH){
    digitalWrite(lmotorpin1,HIGH);
    digitalWrite(lmotorpin2,LOW);
    digitalWrite(rmotorpin1,LOW);
    digitalWrite(rmotorpin2,LOW);
  }
  else{
    digitalWrite(rmotorpin1,LOW);
    digitalWrite(rmotorpin2,HIGH);
    digitalWrite(lmotorpin1,LOW);
    digitalWrite(lmotorpin2,LOW);
  }
}


DOWNLOAD PROGRAM:click here

STEP 4:

connect the power supply to your Arduino and motor driver....

YOUR BOT IS READY TO RACE.......

Sunday, 27 March 2016

Obstacle avoiding Robot using Arduino

     Hey guys in this tutorial we will see how to make an autonomous obstacle avoiding Robot.This robot is designed and programmed in such a way that it avoids collision.The robot basically moves in a forward direction and whenever it detects a object/obstacle in its path it takes an diversion and avoids the collision.

COMPONETS REQUIRED:

  • Arduino UNO
  • HC SR-04(Ultrasonic sensor)
  • ultrasonic sensor clamp(optional)
  • L293D motor driver
  • metal chassis
  • 2x BO motors
  • 1x caster wheel
  • 2x wheels
  • 2x 9v battery
  • 2x dc battery connectors
  • connecting wires


WORKING PRINCIPLE:

 The obstacle avoidance robotic vehicle uses ultrasonic sensors for its movements. A UNO of Arduino family is used to achieve the desired operation. The motors are connected through motor driver IC to Arduino uno. The ultrasonic sensor is attached in front of the robot.Whenever the robot is going on the desired path the ultrasonic sensor transmits the ultrasonic waves continuously from its sensor head. Whenever an obstacle comes ahead of it the ultrasonic waves are reflected back from an object and that information is passed to the arduino. The arduino controls the motors  based on ultrasonic signals.

ULTRASONIC SENSOR:
The ultrasonic sensor is used for obstacle detection. Ultrasonic sensor transmits the ultrasonic waves from its sensor head and again receives the ultrasonic waves reflected from an object.The ultrasonic sensor emits the short and high frequency signal. These propagate in the air at the velocity of sound. If they hit any object, then they reflect back echo signal to the sensor. The ultrasonic sensor consists of a multi vibrator, fixed to the base. The multi vibrator is combination of a resonator and vibrator. The resonator delivers ultrasonic wave generated by the vibration. 

 The ultrasonic sensor actually consists of two parts; the emitter which produces a 40 kHz sound wave and detector detects 40 kHz sound wave and sends electrical signal back to the arduino.
The ultrasonic sensor enables the robot to virtually see and recognize object, avoid obstacles, measure distance. To use this sensor to measure distance, the robot's brain must measure the amount of time it takes for the ultrasonic sound to travel.                                              
  Sound travels at approximately 340 meters per second. This corresponds to about 29.412µs (microseconds) per centimeter. To measure the distance the sound has travelled we use the formula: Distance = (Time x SpeedOfSound) / 2. The "2" is in the formula because the sound has to travel back and forth. First the sound travels away from the sensor, and then it bounces off of a surface and returns back. The easy way to read the distance as centimeters is to use the formula: Centimeters = ((Microseconds / 58.2).

LETS MAKE THE ROBOT:

STEP1:

Fix the wheels on the metal chassis and mount the Dc BO motors on the back wheels and fix a caster wheel in the front.
connect the L293D motor driver with the arduino and dc motors.
CONNECTIONS:
3,6(l293d) to left motor(output)
11,14(l293d) to right motor(output)

2,7,10,15(l293d) to pins 2,3,4,5 of Arduino(inputs)

NOTE: you can use an l293d ic or an readymade module,each module differs so check L293D IC pin diagram to make correct connections.


STEP 2:



connect the ultra sonic sensor with your arduino,
pin 8 of arduino to echo pin 
pin 9 of arduino to trigger pin
vcc-5v ,gnd-gnd

STEP3:
Interface your arduino with arduino IDE software and upload the below program.


#define echopin  8 // echo pin
#define trigpin 9 // Trigger pin
int maximumRange = 30;
long duration, distance;

void setup() {
  Serial.begin (9600);
  pinMode (trigpin, OUTPUT);
  pinMode (echopin, INPUT );
  pinMode (2, OUTPUT);
  pinMode (3, OUTPUT);
  pinMode (4, OUTPUT);
  pinMode (5, OUTPUT);
}
void loop ()
{

  {
    digitalWrite(trigpin,LOW);
    delayMicroseconds(2);
    digitalWrite(trigpin,HIGH);
    delayMicroseconds(10);
    duration=pulseIn (echopin,HIGH);
    distance= duration/58.2;
    delay (50);
    Serial.println(distance);
  }
  
  if (distance >= 30 ){
    digitalWrite(2,HIGH);
    digitalWrite(3,LOW);
    digitalWrite(4,HIGH);
    digitalWrite(5,LOW);
    delay (200);
  }
  
  else if (distance >=15 && distance <= 25) {
    digitalWrite (2,HIGH);
    digitalWrite (3,LOW);
    digitalWrite (4,LOW);
    digitalWrite (5,LOW);
    delay (1000);
  }
 else if (distance < 15){
   digitalWrite (2, LOW);
   digitalWrite (3, HIGH);
   digitalWrite (4, LOW);
   digitalWrite (5, HIGH);
   delay (1000);
   digitalWrite (2,LOW);
   digitalWrite (3,LOW);
   digitalWrite (4,HIGH);
   digitalWrite (5,LOW);
   delay (1000);     
 }
}

DOWNLOAD PROGRAM:click here

STEP 4:

connect the power supply to your arduino and motor driver....

YOUR BOT IS READY TO GO.......

Sunday, 13 September 2015

Getting Started with an Arduino


             Hello Guys,In this tutorial I am assuming that you own a Arduino UNO. I will show you how to connect your Arduino board to the computer and test it with a simple sketch.


1)Get your supplies Ready:


So what do you need to get started 
  1. Arduino board
  2. USB cable(Type A to Type B)
  3. Laptop/PC
  4. Arduino software (IDE)

Download software: Arduino IDE 1.0.5
      Now install the Arduino software in your computer.

2)Connecting the board & Installing Drivers:


 Connect the Arduino board with your computer using the USB cable.A green colour LED will glow indicating the power is on.

 Now you should install the drivers which will allow your computer to interact with your board through USB port.

Installing Drivers in Windows:

   when you plug the the arduino board to the computer a found new hardware wizard window comes up.

   Anyway windows will fail to install the drivers automatically.
Don't worry Just follow the steps below.


  1. Click on the Start Menu, and open up the Control Panel.
  2. While in the Control Panel, navigate to System and Security. Next, click on System. 
  3. Once the System window is up, open the Device Manager.
  4. Look under Ports (COM & LPT). You should see an open port named "Arduino UNO (COMxx)". If there is no COM & LPT section, look under "Other Devices" for "Unknown Device".
  5. Right click on the "Arduino UNO (COmxx)" if not "Unknown Devices" port and choose the "Update Driver Software" option.
  6. Next, choose the "Browse my computer for Driver software" option and click on let me pick the file(ref:pic 6)
  7. Now click Have a Disk  .
  8. Finally, navigate to and select the driver file named "arduino.inf", located in the "Drivers" folder of the Arduino Software download (not the "FTDI USB Drivers" sub-directory). If you are using an old version of the IDE (1.0.3 or older), choose the Uno driver file named "Arduino UNO.inf"
  9. Windows will finish up the driver installation from there.

3) Uploading your First sketch


      Open the arduino software you have downloaded by double clicking on the arduino icon.

                       Now its time to test your board

Step 1: 

Click File -> Example -> Basics -> Blink

Step 2: 

Click Tools->Board
Choose the Right board which you are using from the list of available boards.

Step 3:

Click Tools ->Serial port

Choose the Correct serial port for your board.To know the serial port of the board you can check it in Device manager Under Ports (COM & LPT).It is usally com3 or higher.

Step 4:


Now its time to check your board with an blinking led sketch.

Compile the Blink led program after it click the upload button 
Wait a few seconds - you should see the RX and TX leds on the board flashing. If the upload is successful, the message "Done uploading." will appear in the status bar.


A few seconds after the upload finishes, you should see the pin 13 (L) LED on the board start to blink (in orange). 

If it does then wow congratulation's you have tested your Arduino board and it works fine.

I knew your are too happy after your first hands on experiance with Arduino.
This is just the beginning subscribe for more tutorials!!

Saturday, 29 August 2015

INTRO TO ARDUINO UNO-R3

          Hello guys, you know what an arduino board is. But as a beginner (or) a novice you may face a difficulty in choosing the right board from the wide range of boards in  Arduino family.
               For you  I strongly suggest Arduino UNO–R3 to get started with electronic projects.
In this blog I will be showing you tutorials and projects with Arduino UNO in my future posts.


WHY ARDUINO UNO?

               The arduino UNO is the most used and documented board in the arduino family.
UNO is a great choice for first arduino as it is relatively cheap and very easy to setup and it is the toughest board you can play with.
In rare cases even if you mess up with the board you can just change the ATmega 328p microcontroller for few bucks ( around 6$/200 INR) as UNO is a surface mount version with DIP package .
                                      It is a huge advantage of arduino UNO.

ARDUINO UNO -R3:

            "UNO" means one in Italian and it is named to mark the release of Arduino software IDE 1.0
The latest Arduino UNO R3 was released in 2011 and it is the third revision of UNO boards.

WHAT IS INSIDE AN ARDUINO?

              So shall we see the specifications of this little board so that you can look forward to use all the cool features described in them.

Specifications:

Microcontroller                               ATmega328
Operating Voltage                          5V
Input Voltage (recommended)       7-12V
Input Voltage (limits)                      6-20V
Digital I/O Pins                               14 (of which 6 provide PWM output)
Analog Input Pins                           6
DC Current per I/O Pin                  40 mA
DC Current for 3.3V Pin                 50 mA
Flash Memory                                32 KB (ATmega328) of which 0.5 KB used by bootloader
SRAM                                             2 KB (ATmega328)
EEPROM                                       1 KB (ATmega328)
Clock Speed                                  16 MHZ

MICROCONTROLLER:

             The Arduino UNO is based on ATmega 328p microcontroller and it also has ATmega16U microcontroller.

ATmega 328p: 
              It is the brain of the Arduino and it is a high performance Atmel pico power 8bit AVR RISC based microcontroller which is cable of executing powerful instruction in single clock cycle.

ATmega 16U2:
             This microcontroller takes care of the USB connection and ICSP bootloader.


I/O pins:

The Arduino UNO has 


  • 14 Digital pins(6 PWM) and
  • 6 Analog pins   
DIGITAL PINS: Pin 0 to Pin 13
In which pin 0 and pin 1 are used to receive and transmit serial data.
PWM:  3,5,6,9,10,11   
These 6 pins can be used as PWM(Pulse Width Modulation) pins.Using these pins you can control the voltage in turn you can control the brightness of led,speed of the motor or whatever you wish to by varying the voltage.

ANALOG PINS:  Pin A0 to Pin A5
The main function of Analog pins is reading the values from Analog sensors.



POWER SYSTEM/POWER PINS:

         The Arduino UNO has super convenient power management and buit-in voltage regulation.
Unlike older boards the power source is selected automatically.You can directly power it through USB or external power supply.

The external power supply can be given by
1.  Connecting power source(7-12V DC) to DC power jack (or)
2.  Connecting a battery lead to Vin and Gnd.
NOTE:Don’t try to power it through 5V or 3.3V pins  it will damage the on board regulator.

  • 5V and 3.3V pins can be used to provide power to sensors and modules when connecting it to Arduino.
  • IOREF: This pin provides voltage reference with which the microcontroller operates.


MEMORY:

       ATmega 328p has 32KB of flash memory to store your program and 2KB of SRAM and 1KB of EEPROM.

 

COMMUNICATION:

        UNO has communication protocols like UART Serial commication,SPI and I2C.

UART:
            UNO uses digital pin0(RX) and digital pin1(TX)  for UART TTL serial communication.
I2C:
            UNO uses A4 or SDA pin and A5 or SCL pin are used for I2C communication with
wire library.

  • SCL is the clock signal
  • SDA is the data signal
 NOTE:SDA and SCL pins are not extra pins available in UNO for I2C its an copy of pins A4 and A5.
SPI:
           Pin11:(MOSI)
           Pin12:(MISO)
           Pin13:(SCK)    
  • MOSI(Master Out Slave In)- The Master line for sending data to the peripherals.
  • MISO(Master In Slave Out)-The slave line for sending data to the master.
  • SCK(Serial Clock)- The clock pulse which synchronise data transmission generated by the master.
    Corresponding pins along with SPI library is used for SPI communication.

ICSP headers can be used to program ATmega directly using boot loader.

CLOCK:

      It has 16MHz clock  on board makes it fast and speediest micro controller.

OTHER FEATURES:

  • It  has a reset button to reset the program on chip.  
  • A Led on board is mapped to pin 13  for debugging  and testing  purpose.
  • A power Led to indicate power.
  • Two Led for RX and TX which blinks when the serial communication takes place.
 

            So I hope you  have got all the answers you need to know about what is inside an Arduino UNO.
So why are you waiting for go grab your arduino board from AmazonEbay , Flipkart or from any electronic retail shop near you.

If you already have one tell me what you have done with it in comment box. :-)

Wednesday, 19 August 2015

What is an Arduino? Why Should I Own One?

    If you are wondering what an Arduino board is? And how it can help you to do your own project.
Then this post is for you to get a clear picture of what it is.

      Arduino is a single board micro-controller and it is an open-source hardware which works on Integrated Development Environment(IDE).


                     "Arduino is an open source electronics prototyping platform
                      based on flexible,easy-to-use hardware and software.Its  intended
                      for artists,designers,hobbyists and anyone interested in creating interactive 
                     objects or  Environments"
                                                                                  -arduino.cc



HISTORY:
     Lets know the history of this little master mind.
Arduino was developed in 2005 at Ivera Interaction Institute ,Itally and it was designed by Massimo Banzi,Giancla Martio ,Dave Mellis,David Cuartielles with Nicholas Zambetti.
It was named after one of their kings Arduin of Ivera.

ARDUINO HARDWARE:

Over the time arduino boards have Evolved into different shapes and sizes with different specifications.  
These boards can be classified based on Categories like  
  • Entry level  
  • Enhanced Features
  • Small Size
  • Wearable and
  •  IOT(Internet Of Things)

There are varieties of Arduino boards with different versions are available to serve different purpose with same core functions.

     Some of the popular Arduino boards are
  • Arduino diecimila
  • Arduino duemilanove
  • Arduino UNO
  • Arduino leonardo
  • Arduino mega
  • Arduino nano
  • Arduino due
  • Lillypad arduino
  • ArduinoYUN
  • Arduino robot 
But in this blog we are going to do projects with Arduino UNO and I will give a detailed explanation about Arduino UNO on my next post.


ARDUINO SOFTWARE:

The Arduino uses an open source software IDE (Integrated Development Environment).
It can be used to easily write program codes and upload it to the Arduino board.
This software runs in cross platforms.

Download software: https://www.arduino.cc/en/Main/Software
 

Programming Language:

The Arduino is built around an easy to use programming language that will help the novices learn to code easily.
  It works on a programming language called processing an open source language which works on IDE and it was developed from Wiring language.

Why Should I Own a Arduino?

Well,if you are like me a beginner in electronics who wishes to work with electronic circuits and create a own  interesting  projects but postponding things without knowing where to start and how to do?
                                             Then Arduino is your solution!!!
With Arduino in your hand along with few sensors of your choice you can do many interesting stuff in a short time without great difficulty.
Why Arduino?when there is a lots of other micro-controller boards available?
There are few  reason I prefer Arduino over other boards.

1)It Is Less Expensive

    Most people don't wish to spend too much money on their projects when they are trying to learn new things .With Arduino  you don't need to worry about the expense.
You can buy one at a low cost around  24$ or 1400 INR (for Arduino uno) or you can make your own Arduino board with blue print  and circuit design available online.
The Arduino clones are also available in the market which are half the price of the original one and it works exactly in the same as the original one.

2)Cross Platform  

With Arduino software you don't have to worry about your OS since it is cross platform software you can install it in any OS like Linux,Windows ,Mac OS,Macintosh.

3)Simple and Easy 

It is simple and easy to learn even a armature electronic hobbyist or a school student can understand the concepts and learn it fast and do their own projects in a very short time.


I Strongly recommend Arduino board for Engineering students ,School students and Hobbyists who wish to learn Electronic concepts in a fun filled way.