/*
infrared sensor detector. connect signal of infrared to analog pin 0. as the distance
from an object to sensor increases/decreases, you will increase/decrease
speed of led blinks from HIGH to LOW
*/
int IR_Pin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int IR_Value = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// read the value from the sensor:
IR_Value = analogRead(IR_Pin);
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(IR_Value);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for <sensorValue> milliseconds:
delay(IR_Value);
Serial.println(String("")+ "delay value for LED = "+ IR_Value);
}