0% found this document useful (0 votes)
8 views1 page

Code

The document contains an Arduino program that controls a robot's motors and a pump based on serial input commands. It defines specific actions for forward, backward, left, right movements, and stopping the motors, as well as controlling the pump. The setup initializes the motor pins and the pump, while the loop continuously checks for serial input to execute the corresponding motor commands.

Uploaded by

worldakash42
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Code

The document contains an Arduino program that controls a robot's motors and a pump based on serial input commands. It defines specific actions for forward, backward, left, right movements, and stopping the motors, as well as controlling the pump. The setup initializes the motor pins and the pump, while the loop continuously checks for serial input to execute the corresponding motor commands.

Uploaded by

worldakash42
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

char t;

void setup() {
pinMode(2,OUTPUT); //left motors forward
pinMode(3,OUTPUT); //left motors reverse
pinMode(4,OUTPUT); //right motors forward
pinMode(5,OUTPUT); //right motors reverse
pinMode(7,OUTPUT); //pump
Serial.begin(9600);
digitalWrite(7,HIGH);

void loop() {

if(Serial.available()){
t = Serial.read();
Serial.println(t);
}

if(t == 'F'){ //move forward(all motors rotate in forward direction)


digitalWrite(2,HIGH);
digitalWrite(4,HIGH);
}

else if(t == 'B'){ //move reverse (all motors rotate in reverse direction)
digitalWrite(3,HIGH);
digitalWrite(5,HIGH);
}

else if(t == 'L'){ //turn right (left side motors rotate in forward direction,
right side motors doesn't rotate)
digitalWrite(4,HIGH);
}

else if(t == 'R'){ //turn left (right side motors rotate in forward
direction, left side motors doesn't rotate)
digitalWrite(2,HIGH);
}
else if(t == 'W'){ //turn left (right side motors rotate in forward
direction, left side motors doesn't rotate)
digitalWrite(7,0);
}
else if(t == 'w'){ //turn left (right side motors rotate in forward
direction, left side motors doesn't rotate)
digitalWrite(7,1);
}

else if(t == 'S'){ //STOP (all motors stop)


digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
}
}

You might also like