/
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

 



Related content

Exercise 3 Solution
Exercise 3 Solution
More like this
Exercise 2 Solution
Exercise 2 Solution
More like this
Digital Output : Getting Started
Digital Output : Getting Started
More like this
Exercise 2
Exercise 2
More like this
Exercise 1
Exercise 1
More like this
Digital Input
Digital Input
More like this