Transcript from the "Make the Button Control the LED" Lesson
>> Steve Kinney: What I want to do next is, we already have that LED wired up. What I want to do is kind of marry the two things we were just doing. We can now know when a button is pressed or released. We also have the ability to turn an LED on and off.
[00:00:14] What if, bare with me here, we turn the LED on or off depending on whether or not the button was pressed or released. I know I know. So let's go ahead and take a look at that. To match up with the diagram that I made earlier. The stargrams take a lot of time.
[00:00:37] I put my LED back on a zero. If you wanna leave yours on a five, that'll work. Remember, for turning on and off any pin will work. I just wanted to keep it consistent with the diagram. That felt like the responsible thing to do. So I'm gonna just change my code real quick.
[00:00:53] And I'll say a0. And I'm not gonna do anything with it immediately. Here I can go ahead and turn these into, I'll say, when it's pressed we'll do led.on. And when it's released, do led.off. Cool. And what I'm going to do now is I'm going to deploy that code from the playground.
[00:01:21] All right, good. The code has deployed. I can press the button. The LED turns on. I release the button, the LED turns off. You'll notice that I can't help myself from doing this repeatedly. It's very gratifying, right? I can't, I know. I write professional software applications all day, I do very complicated things.
[00:01:46] And yet this is literally incredibly rewarding for me. So I know that you want to, so just give yourself a second and indulge.