12. Output devices
Add an output device to a microcontroller board you've designed and program it to do something
For this assignment, I designed, milled, and programmed another barduino with a few modifications. Since I plan on using this for my final project, I removed a few unnecessary pins, added a JST female port for a portable battery, and added a logo. One trick I learned after a few failed attempts at soldering in the ATmega 328 is to completely coat each side with a heavy layer of solder irrespective of the copper traces. Then going back over the gloop with the soldering iron and a suction pump and the excess solder will be sucked right off. Additionally, some of the traces weren't neat after milling due to using a dull bit, so I gently used another copper board to sand the traces flat.
As for the output devices, I used an 8 ohm speaker that I connected directly to ground and a digital pin. Considering that I wanted to change the output pitch based on the changing analog input of the force sensors, I decided it would be great to play a musical scale to set a range of tones to be designated per range of analog inputs.
I found a great tutorial on how Arduino process sound here. Basically, a note is played by calling out the frequence of that note. The frequency specifies that the digital output will switch between an on/off state that many numbers of time per second. For example, a frequency of 370 mHz means that the speaker will toggle on/off 370 times every second, generating an 'F#'.
Download the corresponding files here.