Arduino: Use a Button to Toggle an LED

preview_player
Показать описание
Support The Geek Pub by going Premium and get access to all of our plans and member videos:

Support this Channel on Patreon:

In this Arduino Tutorial we cover the basics of having a photoresistor (light sensor) activate (or trigger) an LED!

00:00 - Intro
00:11 - Concept
00:29 - What you need
00:45 - Hardware build
02:20 - Software configuration
03:56 - Completed project
04:14 - More at TheGeekPub!

Detailed article with wiring diagrams and code examples:

Get your very own GEEK PUB UNO here:

PARTS LIST FOR THIS PROJECT:

Find us on Social Media:
Рекомендации по теме
Комментарии
Автор

your code has clear logic and makes sense, thank you

fahtfakcarl
Автор

I honestly feel it might be a good idea for me to learn some basic electronics, because I've spent the last several hours stuck on a problem with push buttons on the ESP32, only to realize it was a simple oversight. Currently working on a Rubik cube solver using JavaScript but sending the solution to the ESP32 for the cube rotations (using servos), so I'm ok on the programming side; but clueless on the electronics side. That one problem really exposed my lack of knowledge. I guess a bit of education in this area can't do any harm.

Anyway, thanks for the tutorial, very clear. And, I'm liking that cable management.

TinyMaths
Автор

Love the video. Can you show how you would change the code for multiple buttons/toggles each with their own led.

Linrox
Автор

Mr. Thanks for your explanation, I learned a lot. One question, how could I do this using an LDR sensor instead of the button? example: when lighting the ldr, turn on the led, the led will stay on until I light it up again to turn off the led.

wandersonsilva-fxcs
Автор

This is good, but the led in your video appears to turn on or off when the button is released? How do you make it so it's when it's pressed?

techtinkerin
Автор

Can you post the same project with pic microcontroller??

anokhautomation
Автор

can this also be achieved with a normal on/off button?

xdmcreamysickalien
Автор

When I press the button and try turning it back on it stays off

reaperofsouls
Автор

Would there be an issue with the code you provided and another microcontroller - say an Arduino Nano 328 in my case?

I am an absolute beginner - literally started tinkering around yesterday after a bit of introduction by a friend.

edit: Nevermind. I found the error.

robertnett
Автор

sorry for rewamping comments 😂

but I reckon that if i push the button without releasing it, the led will not toggle ?

if u confirm, thats gonna gratify me

kursadyilmazoglu
Автор

how can i do it so that i have 2 leds, when i press the button, the first one turns on, the i press it again the first one turns off and the second one turns on, you know what i mean?

moonmatthew