Created
May 14, 2018 12:11
-
-
Save palmenros/f0aedb6ae0d32aa53c0b1ecc29f133a7 to your computer and use it in GitHub Desktop.
Seguidor de linea arduino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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