Created
August 15, 2018 15:02
-
-
Save AungWinnHtut/e47263f94d275180272efa6133337882 to your computer and use it in GitHub Desktop.
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 LED = 13; // Use the onboard Uno LED | |
int obstaclePin = 7; // This is our input pin | |
int hasObstacle = HIGH; // HIGH MEANS NO OBSTACLE | |
void setup() { | |
pinMode(LED, OUTPUT); | |
pinMode(obstaclePin, INPUT); | |
Serial.begin(9600); | |
} | |
void loop() { | |
hasObstacle = digitalRead(obstaclePin); //Reads the output of the obstacle sensor from the 7th PIN of the Digital section of the arduino | |
if (hasObstacle == LOW) //LOW means something is ahead, so illuminates the 13th Port connected LED | |
{ | |
Serial.println("Stop something is ahead!!"); | |
digitalWrite(LED, HIGH);//Illuminates the 13th Port LED | |
} | |
else | |
{ | |
Serial.println("Path is clear"); | |
digitalWrite(LED, LOW); | |
} | |
delay(200); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment