Created
September 21, 2015 10:49
-
-
Save riponroy79/f0ab54a9a80e9decd394 to your computer and use it in GitHub Desktop.
Laser Sensor
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
| // Arduino Based Laser Sensor | |
| // By Nillakash34 | |
| // nillakash34@gmail.com | |
| // fb.com/nillakash34 | |
| int ledPin = 13; // choose the pin for the LED | |
| int lasinput = A0; // Analog pin 0 will be called 'lasersensor' | |
| int lasValue = 0; | |
| void setup() { | |
| pinMode(ledPin, OUTPUT); // declare LED as output | |
| pinMode(lasinput, INPUT); // declare sensor as input | |
| Serial.begin(9600); // Initialize serial communication at 9600 bits per second | |
| } | |
| void loop() { | |
| lasValue = analogRead(lasinput); // Read the input on analog pin 0 (named 'lasersensor') | |
| if(lasValue <= 500) { | |
| digitalWrite(ledPin, HIGH); // Activate digital output pin 13-turn LED ON | |
| delay(100); | |
| digitalWrite(ledPin, LOW); | |
| delay(100); | |
| Serial.println("Laser Detected"); //Show in the Display"Laser Detected" | |
| } else { | |
| digitalWrite(ledPin, LOW); // turn LED OFF | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment