Arduino Tutorials – Lesson 21 – Stepper motor control Using Arduino UNO

Creating stepper motor control program using Arduino UNO

Required Components

  1. Stepper Motor (NEMA17) -1 no
  2. A4988 Stepper Driver -1 no
  3. 12V 2A Adapter -1 no
  4. Arduino Board UNO or MEGA -1 no
  5. Connecting wires -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the servo motor drive to the Arduino UNO.
  3. Connect the Servo motor to their driver circuit.
  4. Connect the external power source to the servo motor.
  5. Connect the Arduino pin 3&4 to driver circuit.
  6. Connect the +5v and ground(gnd) connections respectively.
  7. Check the Circuit Connections.
  8. Check the Arduino program.
  9. Run the Arduino program.

Arduino Program

#include <Stepper.h>
const int stepPin = 3;
const int dirPin = 4;

void setup( )
{
  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);
}
void loop( )
{
  digitalWrite(dirPin,HIGH);
  for(int x = 0; x < 200; x++)
  {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
  }
  delay(1000);
  digitalWrite(dirPin,LOW);
  for(int x = 0; x < 400; x++)
  {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);    
  }
  delay(1000); 
}

Usage

  1. Packaging
  2. Industry automation
  3. Conveyer belt

Projects

  1. Robot arm
  2. Dustbin

Arduino Tutorials – Lesson 20 – Color Sensor Using Arduino UNO

Creating the reflected color when the light sensor shining a white light at an object program using Arduino UNO

Required Components

  1. Arduino UNO -1 no
  2. Color Sensor -1 no
  3. USB cable -1 no
  4. Jumper Wires -7 no

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Color Sensor S0, S1, S2, S3 &Out pins to the Arduino UNO board pins 4,5,6,7 &8 respectively.
  3. Connect the sensor vcc pin to the Arduino UNO 5V pin.
  4. Connect the ground connection respectively.
  5. Check the Arduino program.
  6. Check the Circuit Connections.
  7. Run the Arduino program.

Arduino Program

#define s0 4
#define s1 5
#define s2 6
#define s3 7
#define out 8
int data=0;

void setup()
{
  pinMode(s0,OUTPUT);
  pinMode(s1,OUTPUT);
  pinMode(s2,OUTPUT);
  pinMode(s3,OUTPUT);
  pinMode(out,INPUT);
  Serial.begin(9600);
  digitalWrite(s0,HIGH);
  digitalWrite(s1,HIGH);
}

void loop()
{
  digitalWrite(s2,HIGH);
  digitalWrite(s3,HIGH);
  Serial.print("Red value= ");
  GetData();
  digitalWrite(s2,LOW);
  digitalWrite(s3,HIGH);
  Serial.print("Blue value= ");
  GetData();
  digitalWrite(s2,LOW);
  digitalWrite(s3,LOW);
  Serial.print("Green value= ");
  GetData();
  Serial.println();
  delay(500);
}

void GetData()
{
  data=pulseIn(out,LOW);
  Serial.print(data
  Serial.print("\t");
  delay(20);
}

Usage

  1. Color temperature measurement
  2. RGB LED consistency control
  3. Medical diagnosis systems
  4. Health fitness systems
  5. Industrial process control

Arduino Tutorials – Lesson 19 – Sound And Light Program Using Arduino UNO

Creating LEDs flash program Using Sound sensor

Required Components

  1. Arduino UNO -1 no
  2. Sound sensor -1 no
  3. Resistor 150 ohm -6 no
  4. LEDs -6 no
  5. Connecting wires -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Sound sensor to the Arduino UNO board.
  3. Connect the Arduino UNO board 8, 9 ,10 ,11 ,12 ,13- pins to the LEDs.
  4. Connect the Arduino UNO board A0 pin to the Sound sensor.
  5. Connect the 150 Ohm Resistor to all the LEDs.
  6. Connect Sound sensor board VCC, GND to 5V, GND of Arduino Uno Board.
  7. Check the Cicuit Connections.
  8. Check the Arduino program.
  9. Run the Arduino program.

Arduino Program

int ledPin1= 8; 
int ledPin2= 9;
int ledPin3= 10;  
int ledPin4= 11;
int ledPin5= 12;
int ledPin6= 13;
int sensorPin= A0; 
int val = 0;

void setup( )
{
  pinMode(ledPin1, OUTPUT); 
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  pinMode(ledPin5, OUTPUT);
  pinMode(ledPin6, OUTPUT);
  pinMode(sensorPin, INPUT); 
  Serial.begin (9600);
}

void loop (  )
{
  val =analogRead(sensorPin);
  Serial.println (val);
  if (val >= 127) 
  {
    digitalWrite(ledPin1, HIGH); 
  }else {
    digitalWrite(ledPin1, LOW);
  }
  if (val >= 378) 
  {
    digitalWrite(ledPin2, HIGH);
  }else {
    digitalWrite(ledPin2, LOW);
  }
  if (val >= 505) 
  {
    digitalWrite(ledPin3, HIGH);
  }else {
    digitalWrite(ledPin3, LOW);
  }
  if (val >= 632)
  {
    digitalWrite(ledPin4, HIGH);
  }else 
  {
    digitalWrite(ledPin4, LOW);
  }
  if (val >= 759) {
    digitalWrite(ledPin5, HIGH);
  }else 
  {
    digitalWrite(ledPin5, LOW);
  }
  if (val >= 886)
  {
    digitalWrite(ledPin6, HIGH);
  }else 
  {
    digitalWrite(ledPin6, LOW);
  }
}

Usage

  1. Security system for Office or Home
  2. Spy Circuit
  3. Home Automation
  4. Smart Phones
  5. Ambient sound recognition
  6. Audio amplifier

Projects

  1. Lightning cloud

Arduino Tutorials – Lesson 18 – A Solenoid Valve Control Using Arduino UNO

Creating A Solenoid Valve program using Arduino UNO

Required Components

  1. Solenoid valve -1 no
  2. Darlington Transistor -1 no
  3. Resistor(10K) -1 no
  4. IN4001 Diode -1 no
  5. Arduino UNO -1 no
  6. Bread board -1 no
  7. Connecting wires -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Transistor to the Arduino UNO board & Solenoid valve.
  3. Connect the 10K resistor to the Transistor.
  4. Connect the Power supply to the Solenoid valve.
  5. Connect the Solenoid valve to the Arduino UNO board.
  6. Connect the 10K resistor to the 2nd pin of Arduino UNO board.
  7. Check the Cicuit Connections.
  8. Check the Arduino program.
  9. Run the Arduino program.

Arduino Program

int solenoidPin = 9;
                                   
void setup( )
{
  pinMode(solenoidPin, OUTPUT);          
}

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

Usage

  1. Computer printers
  2. Fuel injection gear
  3. Vehicles like cars
  4. Industrial setting

Arduino Tutorials – Lesson 17 – Soil Moisture Sensor Using Arduino UNO

Creating Soil Moisture Sensor program using Arduino UNO

Required Components

  1. Soil sensor -1 no
  2. Arduino UNO -1 no
  3. Connecting Wires -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Soil moisture to the Arduino UNO board.
  3. Connect the Arduino UNO board A0 pin to the Soil moisture(Analog or Digital).
  4. Connect the interfacing to the Arduino UNO board.
  5. Connect Humidity Sensor board VCC, GND to 5V, GND of Arduino Uno Board.
  6. Check the Cicuit Connections.
  7. Check the Arduino program.
  8. Run the Arduino program.

Arduino Program

int sensorPin = A0;
int sensorValue;
int limit = 300;

void setup( )
{
  Serial.begin(9600);
  pinMode(13, OUTPUT);
}

void loop( )
{
  sensorValue = analogRead(sensorPin);
  Serial.println("Analog Value : ");
  Serial.println(sensorValue);
  if (sensorValue<limit)
  {
    digitalWrite(13, HIGH);
  }
  else{
    digitalWrite(13, LOW);
  }
  delay(1000);
}

Usage

  1. Agricultural science and horticulture
  2. Irrigation planning
  3. Climate research
  4. Solute transport studies
  5. Auxiliary sensors for soil respiration

Arduino Tutorials – Lesson 16 – Humidity Sensor Using Arduino UNO

Creating Humidity Sensor program using Arduino UNO

Required Components

  1. Humidity Sensor(DHT22) -1 no
  2. Arduino UNO -1 no
  3. Connecting wires -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Humidity Sensor to the Arduino UNO board.
  3. Connect the Arduino UNO board 2nd pin to the Humidity Sensor.
  4. Connect Humidity Sensor board VCC, GND to 5V, GND of Arduino Uno Board.
  5. Check the Cicuit Connections.
  6. Check the Arduino program.
  7. Run the Arduino program.

Arduino Program

#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

void setup() 
{
  Serial.begin(9600);
  Serial.println("DHTxx test!");
  dht.begin();
}

void loop( )
{
  delay(2000);
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);
  if (isnan(h) || isnan(t) || isnan(f)) 
  {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  float hif = dht.computeHeatIndex(f, h);
  float hic = dht.computeHeatIndex(t, h, false);
  Serial.print ("Humidity: ");
  Serial.print (h);
  Serial.print (" %\t");
  Serial.print ("Temperature: ");
  Serial.print (t);
  Serial.print (" *C ");
  Serial.print (f);
  Serial.print (" *F\t");
  Serial.print ("Heat index: ");
  Serial.print (hic);
  Serial.print (" *C ");
  Serial.print (hif);
  Serial.println (" *F");
}

Usage

  1. Industrial process &control systems
  2. Office automation
  3. Clothes dryer
  4. Microwave ovens
  5. Printers

Arduino Tutorials – Lesson 15 -Hall Effect Sensor with Arduino UNO

Creating Hall Effect Sensor program using Arduino UNO

Required Components

  1. Hall effect sensor -1 no
  2. magnets -1 no
  3. Arduino UNO -1 no
  4. Connecting wires -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Hall effect Sensor to the Arduino UNO board.
  3. Connect the Arduino UNO board 2nd pin to the Hall effect Sensor(Analog or Digital).
  4. Connect Hall effect Sensor board VCC, GND to 5V, GND of Arduino Uno Board.
  5. Check the Cicuit Connections.
  6. Check the Arduino program.
  7. Run the Arduino program.

Arduino Program

int hallSensorPin = 2;
int ledPin =  13;
int state = 0;

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

void loop( )
{
  state = digitalRead(hallSensorPin);
  if (state == LOW) 
  {
    digitalWrite(ledPin, HIGH);
  }
  else 
  {
    digitalWrite(ledPin, LOW);
  }
}

Usage

  1. Positioning
  2. Speed detection
  3. Current sensing applications
  4. Tachometers
  5. Anti-lock braking systems

Arduino Tutorials – Lesson 14 – Relay Module Using Arduino UNO

Creating relay module test program using Arduino UNO

Required Components

  1. Arduino UNO -1 no
  2. 5V Relay -1 no
  3. Data Cable -1 no
  4. Connecting Wires -4 no

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Relay VCC, GND to the Arduino UNO board 5V, GND properly.
  3. Connect IN pin to Arduino UNO board pin 8.
  4. Check the Arduino program.
  5. Check the Circuit Connections.
  6. Run the Arduino program.

Arduino Program

int relayPin = 8;

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

void loop( )
{
  digitalWrite (relayPin, HIGH);
  delay(2000);
  digitalWrite (relayPin, LOW);
  delay(1000);
}

Usage

  1. Used for signaling and control in railway networks.
  2. Used in electronic circuits and home appliances
  3. In motor control circuits for motor switching, protection as well as control.

Arduino Tutorials – Lesson 13 – Buzzer Module Using Arduino UNO

Creating Buzzer control program using Arduino UNO

Required Components

  1. Buzzer module -1
  2. Arduino UNO -1
  3. Connecting wires -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Buzzer to the Arduino UNO board.
  3. Connect the Arduino UNO board 8th pin to the Buzzer.
  4. Connect Buzzer board VCC, GND to 5V, GND of Arduino Uno Board.
  5. Check the Cicuit Connections.
  6. Check the Arduino program.
  7. Run the Arduino program.

Arduino Program

const int buzzer = 8;

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

void loop()
{
  tone(buzzer, 1000);
  delay(1000);
  noTone(buzzer);
  delay(1000);        
}

Usage

  1. Alarm clock
  2. Wrist watches
  3. Microwave oven
  4. Fire alarms
  5. Medical devices

Arduino Tutorials – Lesson 12 – IR Sensor control Using Arduino UNO

Creating IR Sensor program using Arduino UNO

Required Components

  1. Infrared sensor-1
  2. Arduino board -1
  3. Connecting cables -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the IR Sensor to the Arduino UNO board.
  3. Connect the Arduino UNO board 2nd pin to the IR Sensor.
  4. Connect IR Sensor board VCC, GND to 5V, GND of Arduino Uno Board.
  5. Check the Cicuit Connections.
  6. Check the Arduino program.
  7. Run the Arduino program.

Arduino Program

int IRPin = 2;
int ledPin=13;
int value;

void setup(  )
{
  pinMode (ledPin,OUTPUT);
  pinMode(IRPin, INPUT);
  Serial.begin(9600);
}
void loop(  )
{
  if (digitalRead (IRPin)==HIGH)
  {
    digitalWrite(ledPin,HIGH);
    Serial.print("Sensor is detect,LED is on");
    delay(100);
  }
  else
  {
    digitalWrite(ledPin,LOW);
    Serial.print("signal is cut,LED is off");
    delay(100);
  }
  value = digitalRead(IRPin);
  Serial.println(value);
}

Usage

  1. Flame Monitors
  2. Radiation Thermometers
  3. Moisture Analyzer
  4. Gas Analyzers
  5. IR Imaging Devices