Search the Blog

Thursday, August 15, 2019

Arduino uno board Code of Pic and Place ROBOT

Pic And Place ROBOT is work like Automatic Creane System







#define m11 1
#define m12 0
#define m21 7
#define m22 6
#define m31 3
#define m32 2
#define m41 4
#define m42 5

#define D0 19
#define D1 18
#define D2 17
#define D3 16

void forward()
{
   digitalWrite(m11, LOW);
   digitalWrite(m12, HIGH);
   digitalWrite(m21, LOW);
   digitalWrite(m22, HIGH);
   digitalWrite(m31, LOW);
   digitalWrite(m32, HIGH);
   digitalWrite(m41, LOW);
   digitalWrite(m42, HIGH);
}

void backward()
{
   digitalWrite(m11, HIGH);
   digitalWrite(m12, LOW);
   digitalWrite(m21, HIGH);
   digitalWrite(m22, LOW);
   digitalWrite(m31, HIGH);
   digitalWrite(m32, LOW);
   digitalWrite(m41, HIGH);
   digitalWrite(m42, LOW);
}

void left()
{
   digitalWrite(m11, LOW);
   digitalWrite(m12, HIGH);
   digitalWrite(m21, HIGH);
   digitalWrite(m22, HIGH);
   digitalWrite(m31, LOW);
   digitalWrite(m32, HIGH);
   digitalWrite(m41, HIGH);
   digitalWrite(m42, HIGH);
}

void right()
{
   digitalWrite(m11, HIGH);
   digitalWrite(m12, HIGH);
   digitalWrite(m21, LOW);
   digitalWrite(m22, HIGH);
    digitalWrite(m31, HIGH);
   digitalWrite(m32, HIGH);
   digitalWrite(m41, LOW);
   digitalWrite(m42, HIGH);
}

void Stop()
{
   digitalWrite(m11, HIGH);
   digitalWrite(m12, HIGH);
   digitalWrite(m21, HIGH);
   digitalWrite(m22, HIGH);
   digitalWrite(m31, HIGH);
   digitalWrite(m32, HIGH);
   digitalWrite(m41, HIGH);
   digitalWrite(m42, HIGH);
}

void setup()
{
  pinMode(D0, INPUT);
  pinMode(D1, INPUT);
  pinMode(D2, INPUT);
  pinMode(D3, INPUT);

  pinMode(m11, OUTPUT);
  pinMode(m12, OUTPUT);
  pinMode(m21, OUTPUT);
  pinMode(m22, OUTPUT);
  pinMode(m31, OUTPUT);
  pinMode(m32, OUTPUT);
  pinMode(m41, OUTPUT);
  pinMode(m42, OUTPUT);
}

void loop()
{

  int temp1=digitalRead(D0);
  int temp2=digitalRead(D1);
  int temp3=digitalRead(D2);
  int temp4=digitalRead(D3);

  if(temp1==1 && temp2==0 && temp3==0 && temp4==0)
  forward();

  else if(temp1==0 && temp2==1 && temp3==0 && temp4==0)
  left();

  else if(temp1==1 && temp2==1 && temp3==0 && temp4==0)
  right();

  else if(temp1==0 && temp2==0 && temp3==1 && temp4==0)
  backward();

   else if(temp1==1 && temp2==0 && temp3==1 && temp4==0)
  Stop();
}

No comments:

Post a Comment

Translate