Arduino Tutorials – Lesson 6 – Single LED Control With Single Pushbutton

Creating single LED blink program using push button

Required Components

  1. LED -1 no
  2. 220 Ω Resistor -1 no
  3. 10 KΩ Resistor -1 no
  4. Push button -1 no
  5. Bread Board -1 no
  6. Arduino Board -1 no
  7. Connecting wires -1 Set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect Arduino board 5v and GND pin to the bread board by using wires.
  3. Connect 220 Ω Resistor to the LED Anode (+) pin and cathode (-) pin to Gnd.
  4. Connect 220 Ω Resistor another pin to Arduino pin 9.
  5. Connect 10 k Ω Resistor to the switch button.
  6. Connect switch button another pin to the Arduino pin 7.
  7. When we press the push button LED blinks.
  8. Check the Arduino program.
  9. Check the circuit connections.
  10. Run the Arduino program.

Arduino Program

int ledPin = 9;
int buttonPin = 7;

void setup()
{
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
}


void loop()
{  
  int button = digitalRead(buttonPin);
  if (button==HIGH)
  {
    digitalWrite(ledPin,HIGH);
  } 
  else
  {
    digitalWrite(ledPin, LOW);
  }
}

Usage

  1. Switching operations.

Arduino Tutorials – Lesson 5- Servo Motor Angle Setup Using Arduino UNO

Creating servo motor angle program using Arduino UNO

Required Components

  1. Servo motor(5V) -1 no
  2. Arduino board -1 no
  3. Connecting wires -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect Arduino board 5v and GND pin to the servo motor 5v and GND by using wires.
  3. Connect servo motor data pin to the Arduino UNO pin 9.
  4. Write Arduino code to run motor which angle changes from +90 degree to -90 degree.
  5. Check the Arduino program.
  6. Check the circuit connections.
  7. Run the Arduino program.

Arduino Program

#include <Servo.h>
Servo myservo;
int pos=0;
int stepdelay=10;

void setup(  )
{
  myservo.attach(9);
}

void loop(  )
{
  moveFromTo(0,90);
  delay (1000);
  moveFromTo(90,180);
  delay(1000);
  moveFromTo(180,90);
  delay (1000);
  moveFromTo(90,0);
  delay (1000);
}

void moveFromTo(int From, int To)
{
  if (From <=To)
  {
    for (pos=From; pos <=To; pos +=1)
    {
      myservo.write(pos);
      delay( stepdelay);
    }
  }
  else
  {
    for(pos=From; pos >=To;pos -=1)
    {
      myservo.write(pos);
      delay( stepdelay);
    }
  }
}

Usage

  1. Conveyor Belts.
  2. Camera Auto Focus.
  3. Solar Tracking System.
  4. Metal Cutting & Metal Forming Machines.
  5. Antenna Positioning.
  6. Printing Presses/Printers.

Projects

  1. Robot-Arm.
  2. Sensor dustbin.

Arduino Tutorials – Lesson 4 – Sweep Servo Motor Control Using Arduino UNO

Creating servo motor program using Arduino UNO

Required Components

  1. Servo motor (5V) -1 no
  2. Arduino UNO board -1 no
  3. Connecting wires -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect Arduino board 5v and GND pin to the servo motor by using wires.
  3. Connect servo motor data pin to the Arduino UNO pin 9.
  4. Check the Arduino program.
  5. Check the circuit connections.
  6. Run the Arduino program.

Arduino Program

#include<Servo.h>
Servo servo1;

void setup(  )
{
  servo1.attach(9);
}

void loop(  )
{
  servo1.write(0);
  delay(1000);
  servo1.write(90);
  delay(1000);
  servo1.write(180);
  delay(1000);
}

Usage

  1. Industrial robotics.
  2. CD/DVD players.
  3. Elevators.
  4. Rudders.
  5. Automated doors.

Projects

  1. Robot-Arm.
  2. Sensor dustbin.

Arduino Tutorials – Lesson 3 – Three LED Blink Using Arduino UNO

Creating three LED blink program using Arduino UNO

Required Components

  1. LED -3 no
  2. Resistor 220Ω -3 no
  3. Arduino UNO board -1 no
  4. Bread Board -1 no
  5. Connecting wires -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect Arduino board 5v and GND pin to the breadboard by using wires.
  3. Connect 220 Ω Resistors to the each LED Anode (+) pin and both cathode (-) pin to GND through breadboard.
  4. Connect Arduino 11, 12, 13 pin to the 220 Ω Resistors another end.
  5. Check the Arduino program.
  6. Check the circuit connections.
  7. Run the Arduino program.

Arduino Program

int led1=11;
int led2=12;
int led3=13;

void setup (  )
{
  pinMode (led1, OUTPUT);
  pinMode (led2, OUTPUT;
  pinMode (led3, OUTPUT);
}


void loop (  )
{
  digitalWrite (led1, HIGH);
  digitalWrite (led2, LOW);
  digitalWrite (led3, LOW);
  delay (1000);
  
  digitalWrite (led3, LOW);
  digitalWrite (led1, LOW);
  digitalWrite (led2, HIGH);
  delay (1000);
  
  digitalWrite (led1, LOW);
  digitalWrite (led2, LOW);
  digitalWrite (led3, HIGH);
  delay (1000);
}

Usage

  1. Focused lights.
  2. Residential and business lighting.
  3. Desk lamps.
  4. Lighting for signage.

Arduino Tutorials – Lesson 2 – Double LED blink using Arduino UNO

Creating Double LED blink program using Arduino UNO

Required Components

  1. Led -2 no
  2. Resistor 220Ω -2 no
  3. Arduino board -1 no
  4. Bread Board -1 no
  5. Connecting wires -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect Arduino board 5v and GND pin to the bread board by using wires.
  3. Connect 220 Ω Resistors to the each LED Anode (+) pin and both cathode (-) pin to Gnd.
  4. Connect Arduino 9, 10 pin to the each 220 Ω Resistors another end.
  5. Check the Arduino program.
  6. Check the circuit connections.
  7. Run the Arduino program.

Arduino Program

int led1 = 9;
int led2 = 10;

void setup()
{
  pinMode (led1, OUTPUT);
  pinMode (led2, OUTPUT;
}

void loop()
{
  digitalWrite (led1, LOW);
  digitalWrite (led2, HIGH);
  delay (500);
  
  digitalWrite (led1, HIGH);
  digitalWrite (led2, LOW);
  delay (500);
}

Usage

  1. Reading lights.
  2. Night lights.
  3. Security lights.

Arduino Tutorials – Lesson 1 – Single LED Blink Using Arduino UNO

Creating single LED blink program using Arduino UNO

Required Components

  1. Led – 1 no
  2. Resister 220Ω – 1 no
  3. Arduino UNO board – 1 no
  4. Connecting wires – 1 no

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect 220 Ω Resistor to the LED Anode (+) pin and cathode (-) pin to Gnd.
  3. Connect Arduino pin13 to the 220 Ω Resistor .
  4. Check the Arduino program.
  5. Check the circuit connections.
  6. Run the Arduino program.

Arduino Program

int led1 = 13;

void setup ( )
{
  pinMode (led1, OUTPUT);
}

void loop ( )
{
  digitalWrite (led1, HIGH);
  delay (3000);
  digitalWrite (led1, LOW);
  delay (1000);
}

Usage

  1. TV backlighting.
  2. Smartphone lights.
  3. Automotive lights.
  4. LED Display.

Ball Collecting Robot – Arduino Robots

Ball collecting robot is a mobile controlled wheeled robot which can be used to collect balls in a playing area. This is a prototype project which will be useful to learn about mobile robots. This concept can be extended to build fully functional ball collecting robot.

Component Required

  1. Arduino Nano
  2. Bluetooth
  3. 12V DC Motors (2)
  4. Dc Motor Driver
  5. 12V battery
  6. Servo Motor
  7. Cables & Wires
  8. Robot Wheels
  9. Robot Gripper

Circuit Diagram

Steps

1 :Connect the DC Motors with DC Motor Drive

2: Connect the DC motor drive OUTPUT Pins with Arduino Nano Pins

   Drive Pins                Arduino Nano

      1A                        D3
      1B                        D4
      2A                        D5
      2B                        D6

3: Connect the Servo Motor with Arduino Nano

      wires                  Pins

       Red                    5V
       Black                  GND
       Yellow                 D10

4 : Connect the Bluetooth with Arduino Nano

  Bluetooth               Arduino Nano

   5V                          5V
   GND                         GND
   RX                          TX
   TX                          RX

5 : Check the Connection once

6 : Upload the arduino program

7 : Install the mobile application in the mobile device.

8: Test the robot with mobile application

Arduino Program

#include <AFMotor.h>
#include <Servo.h> 
// Check the motor driver datasheet for motor pin connections
AF_DCMotor rm(1, MOTOR12_64KHZ);  // Right motor
AF_DCMotor lm(4, MOTOR34_64KHZ);  // Left motor
Servo grServo; // Servo motor for gripper
byte incomingByte ;

void setup() 
{ 
   Serial.begin(9600);
  // Set motors speed
   rm.setSpeed(200);  
   lm.setSpeed(200);
   rm.run(RELEASE);
   lm.run(RELEASE);
	grServo.attach(10); // Attach gripper
} 
void loop()
{
   if (Serial.available() > 0) {
    incomingByte = Serial.read(); // Read the input character from bluetooth serial input buffer
  
    if (incomingByte == 'A') 
    {
         grServo.write(120);      // Gripper Open Position
    }
    else if (incomingByte =='B') 
    {
        grServo.write(180);      // Gripper Close Position
    }
    else if (incomingByte == 'C') 
    {
        rm.run(FORWARD);        // Run both motors in forward direction
        lm.run(FORWARD);
    }
    else if (incomingByte == 'D') 
    {
        rm.run(BACKWARD);       // Run both motors in backward direction
        lm.run(BACKWARD);
    }
    else if (incomingByte == 'E') 
    {
        rm.run(BACKWARD);       // Turning Left. Run right motor in backward direction and left motor in forward direction
        lm.run(FORWARD);
    }
    else if (incomingByte == 'G') 
    {
        rm.run(FORWARD);        // Turning Right. Run right motor in forward direction and left motor in backward direction
        lm.run(BACKWARD);
    }
    else if (incomingByte == 'F') 
    {
        rm.run(RELEASE);        // Stop both motors
        lm.run(RELEASE);
    }
   }
   delay(20);
}

Get the motor driver library from https://github.com/adafruit/Adafruit-Motor-Shield-library

Get the code from github : https://github.com/robolabz/ballcollectingrobot

For robot base and gripper design files and mobile application, contact “info at robolabz.com”