From the course: Learning Arduino: Foundations

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Activate an LED with a pushbutton

Activate an LED with a pushbutton - Arduino Tutorial

From the course: Learning Arduino: Foundations

Activate an LED with a pushbutton

- [Narrator] Alright, so I'm still working on the same file, but this time I want to add an L-E-D. So every time we press on the push button, an L-E-D turns on. So I'll go ahead and add the L-E-D to the circuit. So I'm keeping the same arrangement for the push button. I'm going to go ahead and add the L-E-D to the circuit. So I'm doing the same arrangement that I did last time, connect one side to ground. So I'm using the same common ground over here. The other side of the push button goes to a resistor I'm using 330 ohm. And then finally, I'm going to connect that to Arduino and I will choose pin number three. Alright, so now the first thing that we need to do is we need to identify the L-E-D pin. So integer, and I'll give it a name. And the pin that we selected is pin number three. Now in the void setup function, I need to set the L-E-D as an output. So I use pinMode function, and then the LED, and this time it's an…

Contents