Page 6 - Demo
P. 6
Explanation of Code1. int buttonPin = 2; %u2192 Button is connected to digital pin 2.2. pinMode(buttonPin, INPUT); %u2192 Sets pin 2 as input to read button signal.3. In loop():o digitalRead(buttonPin); checks if button is pressed.o If pressed (HIGH) %u2192 LED turns ON.o If not pressed (LOW) %u2192 LED stays OFF. Expected Output / Learning Outcome