250a Firmware Lab

From CCRMA Wiki
Revision as of 22:55, 5 October 2009 by Wendyju (Talk | contribs) (Compiling and uploading firmware code in the Arduino Program)

Jump to: navigation, search

Lab 3: Firmware Programming
Due on Wednesday, October 14th at 5PM

For this lab you need your MaxKit, and Max/MSP or PD on a computer.

The Autonomous Arduino

One of the major motivations for learning how to program firmware for the AVR is the opportunity to have the Arduino hardware do things without being connected to a computer. In this segment of the lab, we work on setting up the Arduino hardware so that it can work in autonomous mode.

Powering your Arduino via Battery

Previously we have powered our Arduino hardware using current from the computer via the USB connnection. However, to operate autonomously, we need to locally supply power. To do this, we will be connecting 9V batteries to our breadboards.

To get power from our 9V batteries, connect the battery connector. The red wire is +9v power, and the black wire is ground.

Looking at the Arduino User Manual, we can see that pin 30 (in the upper left hand corner of the Arduino board) is the Voltage input Vin pin. Connect the red wire to that pin. Use your multimeter to check the voltage on your 5V and 3V3 outputs.

Compiling and uploading firmware code in the Arduino Program

For this class, we assume that you will be adapting existing working code for your own applications. While this is certainly easier than writing firmware from scratch, it does require understanding how existing code functions.

Please upload the following firmware programs from your Arduino program's Sketchbook->Examples->Digital and Analog folders to your Arduino controller and see how they function. Do attach LEDs, buttons or potentiometers, as is appropriate:

* Blink
* BlinkWithoutDelay
* Button (There is a bug in this program. Can you find it?)
* Melody (Use the piezo speakers supplied with the lab for this one.)

Adapting firmware code

Use bits from the previously examined sample Arduino programs to create your own firmware code to create a flashing Metronome that uses a continuous sensor to control the speed of a flashing led and/or beeping tones.

Custom Communication

Another reason that you might want to program the Arduino microcontroller even if you are connected to a laptop or desktop computer is to enable greater control over the communications from the Arduino. In this segment of the laboratory, we learn a wider variety of ways to send data from the Arduino hardware to the computer than we have previously used.

Serial communication with the Arduino software

You might have noticed in the previous lab segment that it can be very hard to know what is going wrong when the Arduino hardware is in autonomous mode. Here, we demonstrate how to send serial communications between the Arduino hardware and the Arduino software.

Sketchbook->Examples->Communication->SerialCallandResponse.

OSC messages with MAX/Msp or PD

Low-latency sensing

One final reason that you would want direct control over the Arduino firmware is that you might have very low-latency sensing needs.

Encoder input

250a 2009