Week 10
Output Devices
This week's assignment: add an output device to a microcontroller board you've designed, and program it to do something.
My goal for this week was to change the color of an RGB LED based on the acceleration sensed by the IMU. I started by
programming my board to just change the color of an RGB LED. I did this part when I was mad last week and wanted to take
a break from dealing with the IMU so I used the SAMD11C board from
that couldn't work with the IMU but had an LED. I wanted to just make the LED change color,
but it wasn't turning on at all. Upon closer inspection with Anthony's help,
we realized that I forgot to give the LED power! I added a jumper wire to connect the LED to 3V3 and everything worked!
I wrote a simple program to change the color of the LED continuously.
Next, I involved the IMU using my successful board from last week. Because of the limited storage on the
SAMD21E, I couldn't write very complicated programs. So I
wrote a program to make the LED red, green, or blue based on whether the z, x, or y-axis was facing downwards. For example,
if the z axis is facing downwards, then the x and y acceleration will be 0 and the z acceleration
will be g (gravitational acceleration) even if the IMU is still. The same logic applies to the other axes.
Using that idea, I wrote a program to detect a flicking gesture by checking if the state of the IMU changes
from z-axis downwards to y-axis downwards. When the gesture is detected, the LED turns on. Now if I stuck
the board to a stick, I would have a very basic magic wand working!