Monday, 10 July 2017

Line follower using Arduino





int a = 4, b = 7, c = 8, d = 5, e = 6, f = 10, g = 11;
int s1, s2, s3;
void setup ()
{
  Serial.begin(9600);
  pinMode (a, INPUT);
  pinMode (b, INPUT);
  pinMode (c, INPUT);
  pinMode(d, OUTPUT);
  pinMode(e, OUTPUT);
  pinMode(f, OUTPUT);
  pinMode(g, OUTPUT);
}
void front()
{
  analogWrite(d, 110);
  analogWrite(e, 0);
  analogWrite(f, 110);
  analogWrite(g, 0);
}
void stp()
{
  analogWrite(d, 0);
  analogWrite(e, 0);
  analogWrite(f, 0);
  analogWrite(g, 0);
}
void right()
{
  analogWrite(d, 190);
  analogWrite(e, 0);
  analogWrite(f, 0);
  analogWrite(g, 0);
}
void left()
{
  analogWrite(d, 0);
  analogWrite(e, 0);
  analogWrite(f, 190);
  analogWrite(g, 0);
}
void loop()
{
  s1 = digitalRead(a);
  s2 = digitalRead(b);
  s3 = digitalRead(c);
  Serial.print(s1);
  Serial.print("   ");
  Serial.print(s2);
  Serial.print("   ");
  Serial.print(s3);
  Serial.println("   ");

  if ((s1 == LOW) && (s2 == HIGH) && (s3 == HIGH))
  {
    front();
  }
  if ((s1 == HIGH) && (s2 == LOW) && (s3 == HIGH))
  {
    right();
  }
  if ((s1 == LOW) && (s2 == LOW) && (s3 == HIGH))
  {
    right();
  }
  if ((s1 == HIGH) && (s2 == HIGH) && (s3 == LOW))
  {
    left();
  }
  if ((s1 == LOW) && (s2 == HIGH) && (s3 == LOW))
  {
    left();
  }
  if ((s1 == HIGH) && (s2 == HIGH) && (s3 == HIGH))
  {
    stp();
  }
  if ((s1 == LOW) && (s2 == LOW) && (s3 == LOW))
  {
    stp();
  }

}

Own IOT website and Hardware Using Node MCU (cyber thinks)

NODE MCU code -- website link  Cyberthinks google drive link  cyberthinks website files #include <ESP8266WiFi.h> #include <ArduinoJ...