/
Exercise 1 Solution

Exercise 1 Solution



C++

Blocks

C++

Blocks

int buttonState = 0; int LEDPin = 11; void setup() { // initialize pin 2 as input and pin 11 as output pinMode(2, INPUT); pinMode(LEDPin, OUTPUT); } void loop() { buttonState = digitalRead(2); // read the button if (buttonState == HIGH) { // do something - here we just blink the LED digitalWrite(LEDPin, HIGH); delay(500); digitalWrite(LEDPin, LOW); delay(500); } }



 

image2020-1-20_22-2-32.png