Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int motor1_Back=7,motor1=8,motor2=4,motor2_Back=2;
- int command ;
- void setup() {
- pinMode(motor1,OUTPUT);
- pinMode(motor1_Back,OUTPUT);
- pinMode(motor2,OUTPUT);
- pinMode(motor2_Back,OUTPUT);
- Serial.begin(9600);
- }
- void loop()
- {
- if (Serial.available() > 0) {
- command = Serial.read();
- Serial.print("command=");
- Serial.println(command);
- if(command==82)
- {
- digitalWrite(motor1,HIGH);
- }
- else if(command==70)
- {
- digitalWrite(motor1,HIGH);
- digitalWrite(motor2,HIGH);
- }
- else if(command==76)
- {
- digitalWrite(motor2,HIGH);
- }
- else if(command==66)
- {
- digitalWrite(motor1_Back,HIGH);
- digitalWrite(motor2_Back,HIGH);
- }
- else if(command==110)
- {
- digitalWrite(motor1_Back,HIGH);
- }
- else if(command==109)
- {
- digitalWrite(motor2_Back,HIGH);
- }
- else if(command==83)
- {
- digitalWrite(motor1,LOW);
- digitalWrite(motor1_Back,LOW);
- digitalWrite(motor2,LOW);
- digitalWrite(motor2_Back,LOW);
- }
- }
- }
Add Comment
Please, Sign In to add comment