// Item Two—Sensor Light
int sensorPin = 2; // IR sensor to be attached to digital pin NO.2
int ledPin = 13; // Digital Piranha LED-R to be attached to digital pin NO.13
// variable sensorState for storing statistics about the status of the sensor int sensorState = 0;
void setup() {
pinMode(ledPin, OUTPUT); // LED is the output unit pinMode(sensorPin, INPUT); // Sensor is the input unit
}
void loop(){
// Read statistics collected from the sensor
sensorState = digitalRead(sensorPin);
// If it is HIGH, LED light will be turned on
if (sensorState == HIGH) {
digitalWrite(ledPin, HIGH);
}
else { // If it is LOW, LED light will be turned off
digitalWrite(ledPin, LOW);
}
}