Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
El codigo para manejar un carrito con motor mas info en https://www.youtube.com/watch?v=bJKBZdasuA8
int MotorD[2] = {10, 11};
int MotorI[2] = {5, 6};
void setup() {
for (int i = 0; i < 2 ; i++) {
pinMode(MotorD[i], OUTPUT);
pinMode(MotorI[i], OUTPUT);
}
}
void loop() {
Izquierda();
delay(1000);
Reposo();
delay(1000);
}
void Reposo() {
digitalWrite(MotorD[0], LOW);
digitalWrite(MotorD[1], LOW);
digitalWrite(MotorI[0], LOW);
digitalWrite(MotorI[1], LOW);
}
void Adelante() {
digitalWrite(MotorD[0], HIGH);
digitalWrite(MotorD[1], LOW);
digitalWrite(MotorI[0], HIGH);
digitalWrite(MotorI[1], LOW);
}
void Reverza() {
digitalWrite(MotorD[0], LOW);
digitalWrite(MotorD[1], HIGH);
digitalWrite(MotorI[0], LOW);
digitalWrite(MotorI[1], HIGH);
}
void Izquierda() {
digitalWrite(MotorD[0], LOW);
digitalWrite(MotorD[1], HIGH);
digitalWrite(MotorI[0], HIGH);
digitalWrite(MotorI[1], LOW);
}
void Derecha() {
digitalWrite(MotorD[0], HIGH);
digitalWrite(MotorD[1], LOW);
digitalWrite(MotorI[0], LOW);
digitalWrite(MotorI[1], HIGH);
}
void Paro() {
digitalWrite(MotorD[0], HIGH);
digitalWrite(MotorD[1], HIGH);
digitalWrite(MotorI[0], HIGH);
digitalWrite(MotorI[1], HIGH);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment