LED MONITOR
For this project, we were tasked to simulate an interactive microcontroller program. This was my first ever attempt with embedded programming, so i wanted to explore how to program outputs that were interrelated. In the end, I wrote a program that counts on a 7-Segment display through button input, with a small LED monitoring system that changed when certain thresholds were passed.
Here's how I did it:
STEP 1:
I Identified the microcontroller I would be working with. The 'SEED STUDIO XIAO (RP2040)' is a very well documented microcontroller with lots of pins. I opted for this in the simulation round also because I'm interested in getting my hands dirty with the Arduino IDE down the line, and the two have a good compatibility.
STEP 2:
The first branch within the monitor system I wanted to resolve was the 7-figure display. When in doubt, sketch it out.
To simplify, The 7-Segment Display has the capacity to display 10 digits, 0-9.
Each digit is represented by either turning on or off an LED Segment, a-g.
We can define a "Truth Table" that says whether a segment, a-g, will be on(1) or off(0) for each of the numbers, 0-9.
We'll pass these instruction patterns to the microcontroller to display the numbers we want.
This initial code just defines the pins for each segment of the display, and maps the buttons to the microcontroller at pins 2 and 3. We also set the display to initialize at 0. Set that anywhere if you're feeling funky.
This is where the magic happens.
We write a conditional statement that checks if the increase or decrease button has been pressed, and increment over the display in the positive or negative.
If the display reaches 9, it resets to 0, and vice versa.
The result is alive:
STEP 3:
That was cool, but i wanted to make a system that helps monitor the progress of the display. For that, I enlisted some colorful LED's
The LED's are set to change color when the display reaches a certain number.
The first LED turns green when the display reaches 3, the second turns yellow at 6, and the third turns red at 9.
The LED's are connected to the microcontroller at pins 4, 5, and 6. I imagine this could be useful in a system that requires a sensorial cue when certain thresholds are reached.
What is that system? I have no idea