Curriculum
Course: Push Button With Led
Login
Text lesson

Output

Output

Expected Output

  • Press Button → LED ON
  • Release Button → LED OFF

Student Observation

  • Arduino internal resistor works automatically.
  • No external resistor needed for button.
  • INPUT_PULLUP uses reverse logic.

Important Note

Why LOW when button is pressed?

Because:

  • Pin is normally connected internally to HIGH.
  • Pressing button connects it to GND.
  • So Arduino reads LOW.

 

 

when Arduino Uno starts up

forever

set 

buttonstate

to

read digital pin

2

if

buttonstate =

1

then

set digital pin 13 output as high

else

set digital pin 13 output as low
×
×

Cart