Arduino Tutorials – Lesson 9 – Joystick Interface on Arduino UNO

Creating position of Joy Stick program using Arduino UNO

Required Components

  1. Arduino UNO -1 no
  2. Joystick Module -1 no
  3. LEDs -5 no
  4. Resistor: 150 ohm -5 no
  5. Breadboard -1 no
  6. Connecting wires -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the 150 Ohm Resistor and Arduino Uno gnd to the LED.
  3. Connect the Arduino Uno Board 2nd pin to the Joy stick.
  4. Connect the Arduino Uno 8 ,9 ,10 ,11th pins to the Joy stick.
  5. Connect the Arduino Uno 5V & gnd to the Joy stick controller.
  6. Connect the Arduino Uno Board A0 & A1 pins to the X -axis & Y-axis.
  7. Check the Circuit Connections.
  8. Check the Arduino program.
  9. Run the Arduino program.

Arduino Program

int joyX=A0;
int joyY=A1;
int button=2;
int buttonState = 0;
int buttonState1 = 0;

void setup(  ) 
{
  pinMode(7,OUTPUT);
  pinMode(button,INPUT);
  digitalWrite(button, HIGH);
  Serial.begin(9600);  
}

void loop(  ) 
{
  int xValue = analogRead(joyX);
  int yValue = analogRead(joyY);
  Serial.print(xValue);
  Serial.print("\t");
  Serial.println(yValue);
  
  buttonState = digitalRead(button);
  Serial.println(buttonState);
  if (xValue>=0 && yValue<=10)
  {
    digitalWrite(10, HIGH);
  }else
  {
    digitalWrite(10, LOW);
  }
  if (xValue<=10 && yValue>=500)
  {
    digitalWrite(11, HIGH);
  }else
  {
    digitalWrite(11, LOW);
  }
  if (xValue>=1020 && yValue>=500)
  {
    digitalWrite(9, HIGH);
  }else
  {
    digitalWrite(9, LOW);   
   }
  if (xValue>=500 && yValue>=1020)
  {
    digitalWrite(8, HIGH);
  }else
  {
    digitalWrite(8, LOW);
  }
  if (xValue>=1020 && yValue>=1020)
  {
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
  }
  if (buttonState == LOW)
  {
    Serial.println("Switch = High");
    digitalWrite(7, HIGH);
  }else
  {
    digitalWrite(7, LOW);
  }
  buttonState1 = digitalRead(7);
  Serial.println(buttonState1);
  delay(100);
}

Usage

  1. Gaming controls
  2. Air craft

Arduino Tutorials – Lesson 8 – LDR Sensor on Arduino UNO

Creating LDR Sensor program using Arduino UNO

Required Components

  1. LED -1 no
  2. LDR -1 no
  3. Resistor 10K Ω -1 no
  4. Resistor 220 Ω -1 no
  5. Bread board -1 no
  6. Arduino UNO board -1 no
  7. Connecting cables -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Arduino UNO A0 pin to the LDR.
  3. Connect the Arduino UNO 13th pin to the LED.
  4. Connect the Arduino Uno 5V, GND to the LDR Sensor using jumper wires.
  5. Check the Arduino program.
  6. Check the circuit connections.
  7. Run the Arduino program.

Arduino Program

const int ledPin=13;
const int ldrPin=A0;

void setup(  )
{
  Serial.begin(9600);
  pinMode (ledPin,OUTPUT);
  pinMode (ldrPin,INPUT);
}

void loop( )
{
  int ldrstatus = analogRead(ldrPin);
  if (ldrstatus<=300)
  {
    digitalWrite(ledPin,HIGH);
    Serial.print("LDR in Dark,LED is ON");
  }
  else
  {
    digitalWrite(ledPin,LOW);
    Serial.print ("LDR in Light,LED Is Off");
  }
}

Usage

  1. Alarm clocks
  2. Street lights
  3. Light intensity meters
  4. Burglar alarm circuits

Projects

  1. Shooting game

Arduino Tutorials – Lesson 7 – Three LEDs Connect With A Single Switch Blink Using Arduino UNO

Creating three LEDs blink program using push button

Required Components

  1. Led -3 no
  2. Resistor(220 ohm) -3 no
  3. Resistor(10K) -1 no
  4. Pushbutton -1 no
  5. Bread Board -1 no
  6. Arduino UNO -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 Ω Resistors to each LED Anode (+) pin and all cathode (-) pin to Gnd.
  4. Connect Arduino pin 9, 10, 11 to the 220 Ω Resistors another pin.
  5. Connect 10 k Ω Resistor to the switch.
  6. Connect switch button another pin to the Arduino pin 8.
  7. When we press the push button 1st time LED1 blinks.
  8. When we press the push button 2nd time LED1 off and LED2 blinks.
  9. When we press the push button 3rd time LED2 off and LED3 blinks.
  10. Repeated last 3steps as per the program.
  11. Check the Arduino program.
  12. Check the circuit connections.
  13. Run the Arduino program.

Arduino Program

int led1=9;
int led2=10;
int led3=11;
int btn=0;
const int buttonpin=8;

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

  pinMode (buttonpin, INPUT);
  Serial.begin(9600);
}

void loop (  )
{
  
  if (digitalRead(buttonpin)== HIGH)
  {
    btn ++;
    Serial.println(btn);
    Lighton(btn);
    delay (500);
  }
  if (btn >=3)
  {
    btn=0;     
  }
}

void  Lighton(int n)
{
  digitalWrite (led1, LOW);
  digitalWrite (led2, LOW);
  digitalWrite (led3, LOW);
  if (n==1){
    digitalWrite (led1, HIGH);
  }
  else if (n==2)
  {
    digitalWrite (led2, HIGH);
  }
  else if (n==3)
  {
    digitalWrite (led3, HIGH);     
  } 
}

Usage

  1. Advertising application.
  2. Decoration purposes.

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.