Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Motor A
- const int motorPin1 = 10; // Pino 14 of L293
- const int motorPin2 = 9; // Pino 10 of L293
- //Motor B
- const int motorPin3 = 7; // Pino 7 of L293
- const int motorPin4 = 6; // Pino 2 of L293
- void setup(){
- //Set pins as outputs
- pinMode(motorPin1, OUTPUT);
- pinMode(motorPin2, OUTPUT);
- pinMode(motorPin3, OUTPUT);
- pinMode(motorPin4, OUTPUT);
- }
- void loop(){
- turnMotorA();
- delay(2000);//Arduino espera este tempo em ms para comecar a próxima linha
- turnMotorB();
- delay(2000);
- turnMotors();
- delay(2000);
- }
- //Declarando funcoes para controle dos motores
- void stopMotors(){
- digitalWrite(motorPin1, LOW);
- digitalWrite(motorPin2, LOW);
- digitalWrite(motorPin3, LOW);
- digitalWrite(motorPin4, LOW);
- }
- void turnMotorA(){
- digitalWrite(motorPin1, LOW);
- digitalWrite(motorPin2, HIGH);
- digitalWrite(motorPin3, LOW);
- digitalWrite(motorPin4, LOW);
- }
- void turnMotorB(){
- digitalWrite(motorPin1, LOW);
- digitalWrite(motorPin2, LOW);
- digitalWrite(motorPin3, HIGH);
- digitalWrite(motorPin4, LOW);
- }
- void turnMotors(){
- digitalWrite(motorPin1, LOW);
- digitalWrite(motorPin2, HIGH);
- digitalWrite(motorPin3, HIGH);
- digitalWrite(motorPin4, LOW);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement