124
redigeringar
(→Bild) |
|||
Rad 15: | Rad 15: | ||
<pre> | <pre> | ||
int LED = 13 ;// define LED pin | int LED = 13 ;// define LED pin | ||
int | int SENSOR = 2; // sensor pin | ||
int val ; // define numeric variable val | int val ; // define numeric variable val | ||
void setup () | void setup () | ||
{ | { | ||
pinMode (LED, OUTPUT) ; // define LED as output | pinMode (LED, OUTPUT) ; // define LED as output | ||
pinMode ( | pinMode (SENSOR, INPUT) ; // define SENSOR as input | ||
} | } | ||
void loop () | void loop () | ||
{ | { | ||
val = digitalRead ( | val = digitalRead (SENSOR) ;// read SENSOR and put it into val | ||
if (val == HIGH) // When the | if (val == HIGH) // When the sensor detects a signal, LED flashes | ||
{ | { | ||
digitalWrite (LED, LOW); | digitalWrite (LED, LOW); |
redigeringar