Arduino Tutorials – பாடம் 9 – Joystick Interface on Arduino UNO

Joy stick நிலையை 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. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. 150Resistor உடன் LED ஐ இணைக்க வேண்டும்.
  3. LED உடன் Ground ஐ இணைக்க வேண்டும்.
  4. Arduino பின்னான 2 ஐ joy stick உடன் இணைக்க வேண்டும்.
  5. Arduino பின்னான 8 ,9 ,10 ,11 ஐ joy stick உடன் இணைக்க வேண்டும்.
  6. Joy stick கண்ட்ரோலர் உடன் +5V மற்றும் ground ஐ இணைக்க வேண்டும்.
  7. X-அச்சு மற்றும் Y -அச்சை Arduino பின்களான A0 மற்றும் A1 உடன் இணைக்க வேண்டும்.
  8. Arduino program ஐ சரி பார்க்க வேண்டும்.
  9. மின்சுற்றை சரி பார்க்க வேண்டும்.
  10. 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 – பாடம் 8 – LDR Sensor on Arduino UNO

Arduino UNO  வை பயன்படுத்தி LDR ஐ கட்டுப்படுத்துவது.

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. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. LDR ஐ LED உடன் Bread Board ன் உதவியுடன் இணைக்க வேண்டும்.
  3. இரண்டு வகையான ரெசிஸ்டர் களை எடுத்து கொள்ளவும் ஒன்று 10K மற்றறொன்று 220 Ohm.
  4. Arduino பின்னான A0 ஐ LDR உடன் இணைக்க வேண்டும்.
  5. Arduino பின்னான 7ஐ LED உடன் இணைக்க வேண்டும்.
  6. Bread board உடன் +5V மற்றும் Ground ஐ ஒயர்களை கொண்டு இணைக்க வேண்டும்.
  7. Arduino program ஐ சரி பார்க்க வேண்டும்.
  8. மின்சுற்றை சரி பார்க்க வேண்டும்.
  9. 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 – பாடம் 7 – Three LEDs Connect With A Single Switch Blink Using Arduino UNO

ஒரு சுவிட்ச் ஐ பயன்படுத்தி மூன்று LED களை ஒளிர வைப்பது.

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. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. மூன்று LED , நான்கு மின்தடைகள் மற்றும் ஒரு புஷ் பட்டன் இதில் உபயோகப் படுத்தப்படுகிறது.
  3. LED கள்அதற்குரிய மின்தடைகளுடன் இணைக்க வேண்டும் மின்தடைகளை நேரடியாக Bread board உடன் இணைக்க வேண்டும்.
  4. Arduino விலிருந்து +5V மற்றும் Ground ஐ Bread Board உடன் ஒயர்களை கொண்டு இணைக்க வேண்டும்.
  5. Arduino பின்களான 3, 4, 5 ஐ LED உடன் இணைக்க வேண்டும்.
  6. Arduino பின் 2 ஐ பட்டன் பின் உடன் இணைக்க வேண்டும்.
  7. பட்டன் ஐ முதல் முறை அழுத்தும் பொது முதல் LED எரிய வேண்டும்.
  8. பட்டன் ஐ இரண்டாவது முறை அழுத்தும் பொது முதல் LED எரியாமல் இரண்டாவது LED எரிய வேண்டும்.
  9. இந்த செயல் ஆனது Program கு ஏற்ப திரும்ப திரும்ப நடை பெற வேண்டும்.
  10. Arduino program ஐ சரி பார்க்க வேண்டும்.
  11. மின்சுற்றை சரி பார்க்க வேண்டும்.
  12. Arduino program ஐ ரன் செய்ய வேண்டும்.

Arduino Program

int led1=3;
int led2=4;
int led3=5;
int btn=0;
const int buttonpin=2;

void setup (  )
{
  pinMode (led1, OUTPUT);
  pinMode (led2, OUTPUT);
  pinMode (led3, OUTPUT);
  Serial.begin(9600);
  btn=0;
}

void loop (  )
{
  if (digitalRead (button pin)== HIGH)
  {
    btn ++;
  }
  if (btn >=3); btn=0;
  serial.print In (btn);
  delay (1000);
}

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 – பாடம் 6 – Single LED Control With Single Pushbutton

ஒரு புஷ் பட்டன் ஐ பயன்படுத்தி ஒரு LEDஐ ஒளிர வைப்பது

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. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. இரண்டு வகையான மின்தடைகளை எடுத்து கொள்ளவும் ஒன்று 10K மற்றறொன்று 220 Ohm.
  3. 220Ohm மின்தடையை LED உடனும் 10K மின்தடையை சுவிட்ச் உடனும் இணைக்க வேண்டும்.
  4. அந்த புஷ்பட்டன் ஐ Arduino pin 7 உடன் இணைக்க வேண்டும்.
  5. Arduino வின் +5V மற்றும் Ground ஐ Bread board உடன் ஒயர்களை கொண்டு இணைக்க வேண்டும்.
  6. Arduino pin எண் 9ஐ LED உடன் இணைக்க வேண்டும்.
  7. புஷ் பட்டன் ஐ அழுத்தும் பொது LED ஒளிர வேண்டும்.
  8. Arduino program ஐ சரி பார்க்க வேண்டும்.
  9. மின்சுற்றை சரி பார்க்க வேண்டும்.
  10. 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 – பாடம் 5- Servo Motor Angle Setup Using Arduino UNO

Arduino UNOவை பயன்படுத்தி servoமோட்டாரின் நிலையை கட்டுப்படுத்துவது.

Required Components

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

Circuit

Steps

  1. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. 5V sweep servo மோட்டார் பயன்படுத்தப்படுகிறது.
  3. Servo மோட்டாருக்கு மூன்று இணைப்புகள் உள்ளன, அதில் ஒன்று data pin, +5v மற்றும் ground.
  4. Arduino 9 ஆவது இணைப்பை நேரடியாக மோட்டார் உடன் இணைக்க வேண்டும்.
  5. மோட்டாரின் நடு இணைப்பை +5V உடன் இணைக்க வேண்டும்.
  6. மோட்டாரின் கடைசி இணைப்பை Ground உடன் இணைக்க வேண்டும்.
  7. ஒவ்வொரு முறையும் மோட்டார் சுழலும்போது +90 அல்லது -90 இருக்குமாறு Program ஐ எழுத வேண்டும்.
  8. Arduino program வை சரி பார்க்க வேண்டும்.
  9. மின்சுற்றை சரி பார்க்க வேண்டும்.
  10. 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 – பாடம் 4 – Sweep Servo Motor Control Using Arduino UNO

Arduino Uno வை பயன்படுத்தி Servo மோட்டாரை சுற்ற வைப்பது.

Required Components

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

Circuit

Steps

  1. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. Servo மோட்டாருக்கு மூன்று இணைப்புகள் உள்ளன, அதில் ஒன்று data pin, +5v மற்றும் ground.
  3. Arduino 9 ஆவது இணைப்பை நேரடியாக மோட்டார் உடன் இணைக்க வேண்டும்.
  4. Arduino வில் உள்ள +5v and ground ஐ bread board உடன் இணைக்க வேண்டும்.
  5. bread board ல் இணைத்த +5v and ground ஐ Servo +5v மற்றும் ground உடன் இணைக்க வேண்டும்.
  6. Arduino program ஐ சரி பார்க்க வேண்டும்.
  7. மின்சுற்றை சரி பார்க்க வேண்டும்.
  8. 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 – பாடம் 3 – Three LED Blink Using Arduino UNO

Arduino வை பயன்படுத்தி மூன்று LED ஐ எரிய வைப்பது.

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. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. மூன்று LED களையும் அதனுடைய மின்தடைகளை கொண்டு bread board உடன் இணைக்க வேண்டும்.
  3. Arduino வில் உள்ள +5v and ground ஐ bread board உடன் இணைக்க வேண்டும்.
  4. Arduino பின்களான 11, 12, 13 ஐ LEDஉடன் இணைக்க வேண்டும்.
  5. Arduino program வை சரி பார்க்க வேண்டும்.
  6. மின்சுற்றை சரி பார்க்க வேண்டும்.
  7. 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 – பாடம் 2 – Double LED blink using Arduino UNO

Arduino வை பயன்படுத்தி இரண்டு LED ஐ ஒளிர வைப்பது.

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. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. Bread board மிகவும் அவசியமானது.
  3. Arduino வில் உள்ள +5v மற்றும் ground இணைப்புகளை bread board உடன் இணைக்க வேண்டும்.
  4. ஒவ்வொரு LED உடன் ஒரு மின்தடையை இணைக்க வேண்டும்.
  5. LED களை சரியான ஒயர்களை கொண்டு இணைக்க வேண்டும்.
  6. Arduino பின்களை சரியான லெட் உடன் இணைக்க வேண்டும்.
  7. மின்தடையின் அடுத்த இணைப்பை ground உடன் இணைக்க வேண்டும்.
  8. Arduino program ஐ சரி பார்க்க வேண்டும்.
  9. மின்சுற்றை சரி பார்க்க வேண்டும்.
  10. Arduino program ஐ ரன் செய்ய வேண்டும்.

Arduino Program

int led1 = 12;
int led2 = 13;

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).
  4. நாடகமேடை விளக்குகள் (spot lights).

Arduino Tutorials – Lesson 33 – DF Player mini using Arduino MEGA2560

Creating DF Player mini test program using Arduino UNO

Required Components

  1. DF Player mini -1 no
  2. Data Cable -1 no
  3. Connecting Wires -1 set
  4. Arduino Uno -1 no
  5. Speaker -1 no
  6. Resistor 1000ohm -1 no

Circuit

Steps

  1. Make sure the components are working properly.
  2. Fix DF Player mini board to the bread board.
  3. Connect Arduino board 5V and GND pin to the DF Player Mini VCC and GND by using wires.
  4. Resistor one end connect to the DF Player Mini RX and the other end connect to the Arduino Uno Board 1 or TX.
  5. The second Resistor one end connect to the DF Player Mini TX and the other end connect to the Arduino Uno Board 0 or RX.
  6. Connect DF Player Mini SPK-1 & SPK-2 pins to the Speker.
  7. Check the Arduino program.
  8. Check the circuit connections.
  9. Run the Arduino program.

Arduino Program

#include "SoftwareSerial.h"
#include <DFMiniMp3.h> 
#define DEBUG 0
class Mp3Notify
{
public:
 static void OnError(uint16_t errorCode)
 {
  Serial.println();
  Serial.print("Com Error ");
  Serial.println(errorCode);
 }
 static void OnPlayFinished(uint16_t track)
 {
  Serial.print("Play finished for #");
  Serial.println(track);
 }
 static void OnCardOnline(uint16_t code)
 {
  Serial.println("Card online ");
 }
 static void OnCardInserted(uint16_t code)
 {
  Serial.println("Card inserted ");
 }
 static void OnCardRemoved(uint16_t code)
 {
  Serial.println("Card removed ");
 }
};
SoftwareSerial secondarySerial(10, 11); 
DFMiniMp3<SoftwareSerial, Mp3Notify> mp3(secondarySerial);
const int LDRpin = A0; 
const int LEDpin = 13; 
int Song=1; 
int ldrStatus;
boolean onStatus = true;
boolean takeLowTime;
long unsigned int timeoutTimer = 0, resetCount = 0;
long unsigned int pause = 2000;

void setup()
{
 Serial.begin(115200);
 if (DEBUG) Serial.println("initializing...");
 pinMode(LDRpin, INPUT); 
 pinMode(LEDpin, OUTPUT);
 mp3.begin();
 mp3.reset();
 uint16_t volume = mp3.getVolume();
 Serial.print("volume ");
 Serial.println(volume);
 mp3.setVolume(20);
 uint16_t count = mp3.getTotalTrackCount();
 Serial.print("files ");
 Serial.println(count);
 uint16_t mode = mp3.getPlaybackMode();
 Serial.print("playback mode ");
 Serial.println(mode);
 if (DEBUG) Serial.println("starting...");
 mp3.playFolderTrack(6, Song);
}

void loop()
{
 ldrStatus = analogRead(LDRpin);
 if (ldrStatus >=300)
  {
    digitalWrite(LEDpin, HIGH);
    mp3.start();
    onStatus = true;
  }
 else 
  {
    digitalWrite(LEDpin, LOW);
    mp3.pause();
  }

 mp3.loop(); 
}

Usage

  1. Fire alarm voice prompts.
  2. Car navigation voice broadcast.
  3. Railway station, bus safety inspection voice prompts.
  4. Electricity, communications, financial business hall voice prompts

Arduino Tutorials – Lesson 32 – L298N Motor Driver with Node MCU

Creating 2 DC Motors control program using Node MCU

Required Components

  1. Node MCU -1 no
  2. L298N Motor Driver -1 no
  3. 9V Battery -1 no
  4. 5V DC Motor -2 no
  5. Motor wheel -2 no
  6. Cable -1 no
  7. Jumper Wires -7 no

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the 5V Battery to the L298N Motor Driver.
  3. Connect the ENA, IN1, IN2, IN3, IN4, ENB pins to the Node MCU pins D2, D0, D1, D7, D6, D5 properly.
  4. Connect the DC motor pins to the motor driver output pins.
  5. Connect the Node MCU ground connection to the driver gnd respectively.
  6. Connect the Power to the NodeMCU.
  7. Check the Arduino program.
  8. Check the Circuit Connections.
  9. Run the Arduino program.

Arduino Program

#include <ESP8266WiFi.h>
const char* ssid = "*****";
const char* password = "*********";
int motor1pin1 = 16; //D0
int motor1pin2 = 5; //D1
int enPin1 = 4; //D2
int motor2pin1 = 13; //D7
int motor2pin2 = 12; //D6
int enPin2 = 14;//D5
WiFiServer server(80);

void setup() 
{
  Serial.begin(115200);
  delay(10);
  pinMode(motor1pin1, OUTPUT);
  pinMode(motor1pin2, OUTPUT);
  pinMode(enPin1, OUTPUT);
  digitalWrite(enPin1, HIGH);
  pinMode(motor2pin1, OUTPUT);
  pinMode(motor2pin2, OUTPUT);
  pinMode(enPin2, OUTPUT);
  digitalWrite(enPin2, HIGH);
  
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) 
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  server.begin();
  Serial.println("Server started");
  Serial.print("Use this URL to connect: ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/");
}

void loop() 
{
  WiFiClient client = server.available();
  if (!client) 
  {
    return;
  }
  Serial.println("new client");
  while(!client.available())
  {
    delay(1);
  }
  String request = client.readStringUntil('\r');
  Serial.println(request);
  client.flush();
  int value,value1 = LOW,value2 = LOW,value3 = LOW,value4 = LOW;
  if (request.indexOf("/MotorForward") != -1)
  {
    digitalWrite(motor1pin1, HIGH);
    digitalWrite(motor1pin2, LOW);
    digitalWrite(motor2pin1, HIGH);
    digitalWrite(motor2pin2, LOW);
    delay(1000);
    value1 = HIGH;
    value2 = LOW;
    value3 = HIGH;
    value4 = LOW;
  }
  if (request.indexOf("/MotorBackward") != -1)
  {
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, HIGH);
    digitalWrite(motor2pin1, LOW);
    digitalWrite(motor2pin2, HIGH);
    delay(1000);
    value1 = LOW;
    value2 = HIGH;
    value3 = LOW;
    value4 = HIGH;
  }
  if (request.indexOf("/MotorLeft") != -1)
  {
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, HIGH);
    digitalWrite(motor2pin1, HIGH);
    digitalWrite(motor2pin2, LOW);
    delay(1000);
    value1 = LOW;
    value2 = HIGH;
    value3 = HIGH;
    value4 = LOW;
  }
  if (request.indexOf("/MotorRight") != -1)
  {
    digitalWrite(motor1pin1, HIGH);
    digitalWrite(motor1pin2, LOW);
    digitalWrite(motor2pin1, LOW);
    digitalWrite(motor2pin2, HIGH);
    delay(1000);
    value1 = HIGH;
    value2 = LOW;
    value3 = LOW;
    value4 = HIGH;
  }
  if (request.indexOf("/MotorStop") != -1)
  {
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, LOW);
    digitalWrite(motor2pin1, LOW);
    digitalWrite(motor2pin2, LOW);
    delay(1000);
    value1 = LOW;
    value2 = LOW;
    value3 = LOW;
    value4 = LOW;
  }
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println(""); //  do not forget this one
  client.println("<!DOCTYPE HTML>");
  client.println("<html>");
  client.print("motor is now: ");
  
  if(value1 == HIGH && value2 == LOW && value3 == HIGH && value4 == LOW ) {
    client.print("Forward");
  }
  else if(value1 == LOW && value2 == HIGH && value3 == LOW && value4 == HIGH  ) {
    client.print("Backward");
  }
  else if(value1 == LOW && value2 == HIGH && value3 == HIGH && value4 == LOW  ) {
    client.print("Left");
  }
  else if(value1 == HIGH && value2 == LOW && value3 == LOW && value4 == HIGH  ) {
    client.print("Right");
  }
  else if(value1 == LOW && value2 == LOW && value3 == LOW && value4 == LOW  ) {
    client.print("Stop");
  }
  client.println("<br><br>");
  client.println("<a href=\"/MotorForward\"\"><button>Forward </button></a>");
  client.println("<a href=\"/MotorBackward\"\"><button>Backward </button></a><br />");
  client.println("<a href=\"/MotorLeft\"\"><button>Left </button></a>");
  client.println("<a href=\"/MotorRight\"\"><button>Right </button></a><br />");
  client.println("<a href=\"/MotorStop\"\"><button>Stop </button></a>");
  client.println("</html>");
  delay(1);
  Serial.println("Client disonnected");
  Serial.println("");
}

Usage

  1. Drive DC motors
  2. Drive Stepping motors
  3. In Robotics

Projects

  1. Diwa Robot