LED That Needs Some Time
In this project, I first made a simple circuit that had a delay of 10 seconds after you press the button, so the user must wait a while for the timid light to turn on. Once the user lets go of the button, it immediately turns off. I had some trouble to start, however. My code was working and properly completing that sequence, but the LED was blinking to start, rather than staying off. I’m not exactly sure why this was happening — I’m thinking maybe it was holding onto the code from my last project? But, when I pressed the button, like I said, it worked fine. Instead of turning off completely when I let go of the button, it stayed blinking though. I went to the examples that Arduino had to offer and copied that and changed some stuff around to match my setup, and the blinking went away. So, it must’ve been something with my code, but I couldn’t put my finger on it.
Next, I was attempting to implement a button press count on top of the 10 second waiting period, but once I plugged the code from the lab example in, it didn’t do anything. I’m pretty confident I have it right, but I can’t identify what’s going wrong. After getting the button press count going, I was going to try and change the amount of time the user has to wait, based on how many times it’s been pressed. Like, if the user doesn’t wait and keeps pushing the button, expecting it to turn on right away, the wait would get longer. I wasn’t able to get that far though, because I can’t say I’m too familiar with Arduino coding and how to identify the mistakes in my code.
Below is a screenshot of my code up until it didn’t work for me, as well as a photo of my breadboard.