Category: Others Sensors
SKU: 2216
int Led = 13 ;// Declaration of the LED output pin int Sensor = 10; // Declaration of the sensor input pin int val; // Temporary variable
void setup () { pinMode (Led, OUTPUT) ; // Initialization output pin pinMode (Sensor, INPUT) ; // Initialization sensor pin }
void loop () { val = digitalRead (Sensor) ; // The current signal at the sensor will be read if (val == HIGH) //
If a signal was detected , the LED will light up { digitalWrite (Led, LOW); } else { digitalWrite (Led, HIGH); } }