Created
May 15, 2018 01:32
-
-
Save liz-miller/5c976f644f3a80ccd27ffee452331e65 to your computer and use it in GitHub Desktop.
Robot Car Using Arduino | Part 4 (Beginner Bots)
This file contains 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
/* | |
* Using IR Sensors for Line Following & Avoidance | |
* Configures IR Sensors for data collection | |
* Developed for the Beginner Bots lesson series on www.learnrobotics.org/blog | |
* Written by Liz Miller | |
* 5/14/2018 | |
*/ | |
/** Global Variables **/ | |
int leftIR = 2; | |
int rightIR = 12; | |
void setup(){ | |
// Setup the serial communication | |
Serial.begin(9600); | |
// both IR sensors are INPUTS | |
pinMode(leftIR, INPUT); | |
pinMode(rightIR, INPUT); | |
} | |
// get readings from the leftIR sensor & display on serial monitor | |
void loop(){ | |
//create a variable to store the reading | |
int leftIRvalue=digitalRead(leftIR); | |
//display the reading in the Serial Monitor | |
Serial.println(leftIRvalue); | |
//re-read every 5000 miliseconds (5 seconds) | |
delay(5000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment