Skip to content

Instantly share code, notes, and snippets.

@palmenros
Created May 14, 2018 12:11
Show Gist options
  • Save palmenros/f0aedb6ae0d32aa53c0b1ecc29f133a7 to your computer and use it in GitHub Desktop.
Save palmenros/f0aedb6ae0d32aa53c0b1ecc29f133a7 to your computer and use it in GitHub Desktop.
Seguidor de linea arduino
int motorLeft = 5;
int motorRight = 6;
int sensorLeft = 8;
int sensorRight = 9;
void setup() {
//Salidas
pinMode(motorLeft, OUTPUT);
pinMode(motorRight, OUTPUT);
//Entradas
pinMode(sensorLeft, INPUT);
pinMode(sensorRight, INPUT);
}
void loop() {
// digitalWrite(motorLeft, LOW);
// digitalWrite(motorRight, HIGH);
//
// delay(1000);
//
// digitalWrite(motorRight, LOW);
// digitalWrite(motorLeft, HIGH);
//
// delay(1000);
bool isWhiteLeft = digitalRead(sensorLeft);
if(isWhiteLeft)
{
digitalWrite(motorLeft, HIGH);
}
else
{
digitalWrite(motorLeft, LOW);
}
bool isWhiteRight = digitalRead(sensorRight);
if(isWhiteRight)
{
digitalWrite(motorRight, HIGH);
}
else
{
digitalWrite(motorRight, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment