PoE: Finishing Lab 1
After we resolved the minuscule problems affecting our progress on the lab, Ashley and I worked diligently to catch up and even worked over the weekend for a long period to complete both parts of the code.
Part I: Four Modes with a Single Button
We had designed the operations of the four modes to be switched between but we were still figuring out the "switching" mechanism on the Saturday before the due date. Many of the examples we had seen were too elaborate and we wanted a simple solution. We found one by using millis(), a pushCounter and debounce operations. Millis() is a way to keep track of time, without stopping the entire program (i.e. delay), and we can use it for comparisons between the current timespan and a set interval to form different flashstates. On the other hand, a "button state change detection" tutorial showed us how to count presses of a button and cycle through four states. However, many times the Arduino will read several button presses when only one was intended: to fix that issue, a debounce operation is formulated to ensure that the code checks for a single press.Part II: Flashing Speed based on Variable Resistance
Using a potentiometer, we were able to alter the speed at which the LEDs flashed in button state #2. For a while, we were dumbfounded and could not debug our code to understand why it was not accurately collecting the POT and modifying the behavior, until we had the "bright" epiphany that POTs transfer analog signals, not digital signals. Arduino's have select pins for analog and digital devices: lo and behold, we had placed the POT in a non-analog pin. Once we fixed that, everything fell into place and we were able implement the code into our set from Part I. By the end of the weekend, we had completed the entire assignment and we were much happy campers.
Comments
Post a Comment