Led with push button arduino

broken image

We then declare two more variables, one for the LED pin and the other one for BUTTON pin, which are 2 and 6 respectively. In order for the sketch to keep track of the state of the LED, we need to first declare a boolean variable with a default as false.Įach time the LED changes its state, we will store the state in this variable. Understanding the Push Button Controlled Sketch During this stage both yellow LEDs on the STEMTera™ Breadboard will start blinking indicating the Arduino IDE is uploading the sketch to the STEMTera™ Breadboard.

broken image

After the compilation is completed, the Arduino IDE will start to upload the compiled sketch into the STEMTera™ Breadboard. Once saved, the Arduino IDE will start to compile the sketch. Enter Excercise_4 into the filename field and click save.

broken image
broken image

Boolean LEDState = false int LED = 2 int BUTTON = 6 void setup () Ĭlick Upload, and the Arduino IDE will prompt you to Save sketch folder as.

broken image