Stap 2: Codering: na het uploaden van de schets, druk op de knop en de LED zal op. Als het wordt vrijgegeven, zal de LED zitten werden vandoor.
//Push Buttonconst int buttonPin = 2; //The Button Pin const int ledPin = 13; //The LED Pin int buttonState = 0; //To store the state of the button void setup() { pinMode(ledPin, OUTPUT); //Set the LED Pin to be output pinMode(buttonPin, INPUT); //Set the button Pin to be input } void loop(){ buttonState = digitalRead(buttonPin); //read the state of the button // If the button is pressed, the button state will be HIGH if (buttonState == HIGH) { digitalWrite(ledPin, HIGH); // If button state is HIGH, then turn on LED } else { digitalWrite(ledPin, LOW); // If button state is LOW, then turn off LED } }