Arduino Tutorial 28: Using a Pushbutton as a Toggle Switch

preview_player
Показать описание
You guys can help me out over at Patreon, and that will help me keep my gear updated, and help me keep this quality content coming:

In this lesson we learn how to use a pushbutton as a toggle switch in Arduino Projects. This uses the same circuit as was used in Lesson 27, but we add the toggle feature to the software.

You can get the kit I am using for this series at the following link:

Also, you can get the Mastech Digital Voltmeter I am using here:

Check out our most awesome web site here:

#Arduino
Рекомендации по теме
Комментарии
Автор

please don't stop after lesson 68! this is so awesome! You are a very good teacher, and there is no one out there like you :D

northadventure
Автор

Loving the series. Drinking beer though, kids and wife are asleep and I'm geeking out in the garage.

jasonengblom
Автор

You sir, are the Organic Chemistry Tutor of Arduino. I always go to your videos if I want to continue in learning arduino. Great teacher, love to see more of your videos.

johnvincentjimar
Автор

Hi, Paul...got to be honest with you, I couldn't work this one out by myself! The problemo was a tad confusing to solve, Old Bean, and after many cups of tea and a whole lotta head scratching and coding errors, I gave up and admitted defeat. The answer to the problem was even harder than I had imagined, so it was a good job that you went on to explain how to overcome this particular problem. Thanks again from across the pond....hope all's well over there with you and family, what with all this Coronavirus malarky. Stay in...stay safe...and stay "switched the pun. Regards....the Grumpy Limey.

mikemanny
Автор

As a professional programmer, I thought I could do this on my 1st trial. I finally got it to work (after trying hundreds of times, with sips of coffee, and believing holding my breath will help) when I found out that delaying the loop was my only solution. I had doubts that what I did wasn't the best way of doing it. And then I saw it at 18:42 that explained what I was missing. And now I can't sleep because of the coffee :) Nevertheless, I finally felt the true satisfaction of saying

erwinvelasquez
Автор

I've finished 28 lessons in 4 days and have completed all the homework and lessons including this one. I retired from teaching jr high coding and robotics. We never got into programming Arduino and I always wanted to, so I bought an Ellego and Vilros kit and when they arrived, I started on your lessons and I am having a blast.

karlgross
Автор

Have to admit, this one stumped me. Thanks for walking us through it.

travisrichardson
Автор

Hi Paul! Your Arduino tutorials are amazing. Your teaching approach is "most excellent" and inspirational! I tried this tutorial and solved it with a while loop and two if statements. It was a great feeling to achieve this on my own. Keep up the good work, sir! Thanks again!

patrickdelvisohopkins
Автор

Hey Paul, I'm really enjoying your new Arduino series. Please keep the lessons coming. I can tell you are a great teacher and wished you had been my high school science teacher many years ago. I often feel like I am back in high school science class during the sessions.
This was the most challenging exercise to date. Took me a couple of tries to dust off enough brain cells to reach a solution. I always try to complete the lesson before watching your solution. BTW, I am using parts of your series as inspiration in teaching my six year old grandson about electronics. He loves working with the Arduino.

alanoestacado
Автор

After hours of banging my head against a wall I finally managed to get it working, with a bit of help from google i admit. I did it a bit differently, I made a counter and each time you press the button it adds 1. Then if the count is at an odd number the led is off, if its an even number it turns on

jamess
Автор

After banging my head against a wall for a microsecond, I got my version running before watching the video. (my secret: I did hold my breath)

kenmeyer
Автор

Thank you very much. Great. I've learned to do it with millis(), not delay()

vladstrulev
Автор

I attempted this on my own, and got as far as assigning an independent tracker - in my case I used a boolean. What I did not think of was using &&, so I kept falling down, cycling through random states. I also did not think of placing a small delay in the loop to make things a little cleaner; that was a very useful lesson. I then watched through and, although I wasn't able to work through it alone, the lesson afterwards made a lot more sense for having at least tried! Thanks Paul!

Codablaze
Автор

18:04 is the funniest part on this series yet! Thanks Paul!

nortetrading
Автор

I was lost. You had to 'baby step' me through this one and that's okay.
I'm here to learn. And you sir, are a teacher.

libbytardalo
Автор

I got it myself by using 3 if statements and an On variable with 3 states 0, 1, & 2.
If button = 0 & On = 0 turn led HIGH & On = 1
If button = 1 & On = 1 turn led HIGH & On = 2
If button = 0 & On = 2 turn led LOW & On = 0

daveflatters
Автор

I started out wanting to get a Technicians license for Ham Radio. Flash forward two years later and I have an extra class license, I went back to school to become certified in IoT, just so I could build my own SDR radio. I now teach Arduino and and Raspberry Pi classes to teenagers. I built an electronics lab in my house as well. I decided to work through all your videos because I recommend them to anyone wishing to learn this type of material. My teaching has greatly improved due to your videos. I am so glad that you explain the math and get students to try things on their own. I came up with a similar sketch (although I prefer to call it code) when trying to do it on my own. I'm currently working on a self driving robot car based on the Arduino platform. I could do this stuff all day and night! Thanks for the great lessons!

hughpatterson
Автор

I tried many ways but never succeeded ..after watching this video i am feeling confident.. thanks so much

prankshot
Автор

I have to admit that this one completely kicked my butt. I completely overthought it.

wannabefunnyman
Автор

As always- excellent, practical explanation - including debouncing the switch. My solution used logical not (!) on LEDState in the if statements.

quaternion-pi
visit shbcf.ru