User manual

Ausgabe 19.05.2017 Copyright by Joy-IT 23
By pressing the buon, the LED will light up.
In this program, an if query is used.
int ledpin=11; // initalises PIN 11
int inpin=7; // initialises PIN 7
int val; // defines „Val”
void setup()
{
pinMode(ledpin,OUTPUT); // sets LED PIN to „OUTPUT“
pinMode(inpin,INPUT); // sets button PIN to „INPUT“
}
void loop()
{
val=digitalRead(inpin); // reads value of PIN 7
// assigns to „Val“
if(val==LOW) // checks if button is pressed
// if so, LED lights up
{ digitalWrite(ledpin,LOW);}
else
{ digitalWrite(ledpin,HIGH);}
}
If the buon is pressed, the LED will light up.
Otherwise it will stay o.