Difference between revisions of "250a Firmware Lab"

From CCRMA Wiki
Jump to: navigation, search
(Serial communication with the Arduino software)
(Powering your Arduino via Battery)
Line 14: Line 14:
 
To get power from our 9V batteries, connect the battery connector. The red wire is +9v power, and the black wire is ground.
 
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 [http://gravitech.us/Arduino/NANO30/Arduino_Nano3_0.pdf 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.
+
Looking at the [http://gravitech.us/Arduino/NANO30/Arduino_Nano3_0.pdf 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 coming out on your 5V and 3V3 outputs.
 +
 
 +
Secure your battery using electrical tape!
  
 
=== Compiling and uploading firmware code in the Arduino Program ===
 
=== Compiling and uploading firmware code in the Arduino Program ===

Revision as of 01:42, 7 October 2009

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 coming out on your 5V and 3V3 outputs.

Secure your battery using electrical tape!

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 folders to your Arduino controller and see how they function. Do attach LEDs, buttons, as is appropriate:

* Digital->Blink
* Digital->BlinkWithoutDelay
* Analog->Fading
* Digital->Button (There is a bug in this file. Can you find it?)

Modify the following programs:

* Digital->Melody: Use the piezo speakers supplied with the lab for this one. Change the song. Incorporate some user interaction so that the song does not loop endlessly. 
  • Analog->AnalogInput: Change the code so that you create a digital metronome whose speed can be controlled by a continuous sensor.

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 send serial communications between the Arduino hardware and the Arduino software.

  • Sketchbook->Examples->Analog->Smoothing: Use the Serial Monitor (icon on the far left on the Arduino software toolbar) to get data back from the Arduino.
  • 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