This week’s lab was a real challenge. Both the software and hardware had their fair share of hoops to jump through. Most of it really wasn’t that difficult, I just had trouble typing out the logic that was required, and then trying to set up the breadboard properly. There were three exercises involving digital inputs and outputs. Three separate Arduino sketches were constructed to get the desired effects shown in the GIFs below.
Below: This was the first exercise, get the L.E.D.s to blink faster at the push of the button. This was done by shortening the pause in between on and off when the button was pressed. Then resuming to the normal set pause time when the button wasn’t being pressed. Unfortunately you can see the last L.E.D. on the left isn’t blinking. I took this video after I originally finished the sketch, and then as my learning curve began to grow, the L.E.D. decided to call it quits, which was my mistake. I’ll have more on that later, Always take videos and pictures first!
These next two sketches took a lot of time to think through what was happening and put that logic into the code. At first I found my sketches to be way too complex for what was happening. I had duplicate code written that wasn’t necessary, and I struggled to get the program running. One cause for trouble was the bounce library, I didn’t quite understand why I needed it, and I couldn’t understand how to incorporate it properly. I took the library out all together, and found I could still get the sketch to run.
Below: This was the first video I took, of the second exercise, you can see that the tall orange L.E.D. on the left is working. The most frustration that this exercise caused for me was getting the button to do what I told it. I couldn’t figure out how to write the sketch properly so the lights would respond to my input. But once I restructured my loop in the proper if else statements the button was now performing how it needed to, to run this sketch. It’s hard to tell from the .GIF but the lights are blinking on and off faster and faster as the button is pressed.
This last exercise (part 3) was certainly the most fun and provided a great learning experience. At first, I could only get the L.E.D.s to light up consecutively going one way, and it wasn’t at the push of a button. Then I get it to work one way with the push of a button, then finally both ways. The issue was I had too many delays in my loop, and my for loops weren’t counting up and down the Arduino pins correctly. The most interesting part though had to do with the addition of the second button.
I essentially slapped a second button on the breadboard parallel to the first button and connected one end to the positive strip of the board and the other to the negative strip of the board. Well it turns out that I created a short circuit in doing so. The button had no resistor either. I would press the second button while the sketch was running through the Arduino, and then the Arduino would momentarily shutoff, and my computer would disconnect the port it was connected to! I still wasn’t sure what was going on until I touched my Arduino and it was VERY hot, it burned me! So I disconnected the jumper wire I had going from ground to the button, and mimicked the layout of the first button. Instead of a jumper wire, I used a resistor. I then reactivated my port, and ran the sketch, and the buttons did exactly what they were supposed to do.