Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Robot Oficina
- char letra;
- int pin3 = 8;
- int pin4 = 9;
- int pin5 = 10;
- int pin6 = 11;
- void setup() {
- Serial.begin(9600);
- pinMode(pin3,OUTPUT);
- pinMode(pin4,OUTPUT);
- pinMode(pin5,OUTPUT);
- pinMode(pin6,OUTPUT);
- }
- void loop() {
- letra = Serial.read();
- switch(letra){
- case 's':
- Serial.println("MOTOR A and B RUN ");
- digitalWrite(pin3,HIGH); // Motor A
- digitalWrite(pin4,LOW); // Motor A
- digitalWrite(pin5,HIGH);
- digitalWrite(pin6,LOW);
- break;
- case 'w':
- Serial.println("MOTOR A and B BACK ");
- digitalWrite(pin3,LOW); // Motor A
- digitalWrite(pin4,HIGH); // Motor A
- digitalWrite(pin5,LOW); // MOtor B
- digitalWrite(pin6,HIGH); // MOtor B
- break;
- case 'p':
- Serial.println("MOTOR A and B STOP ");
- digitalWrite(pin3,LOW); // MOtor B
- digitalWrite(pin4,LOW); // MOtor B
- digitalWrite(pin5,LOW); // MOtor B
- digitalWrite(pin6,LOW); // MOtor B
- break;
- case 'd':
- Serial.println("MOTOR 3 DIRECAO: (DIREITA)");
- digitalWrite(pin3,LOW);
- digitalWrite(pin4,HIGH);
- delay(40);
- digitalWrite(pin5,HIGH);
- digitalWrite(pin6,LOW);
- delay(40);
- break;
- case 'a':
- Serial.println("MOTOR 3 DIRECAO: (ESQUERDA");
- digitalWrite(pin3,HIGH);
- digitalWrite(pin4,LOW);
- delay(40);
- digitalWrite(pin5,LOW);
- digitalWrite(pin6,HIGH);
- delay(40);
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement