CECS Home | ANU Home | Search ANU
The Australian National University
ANU College of Engineering and Computer Science
Research School of Computer Science
Printer Friendly Version of this Document

UniSAFE

Operating Systems Implementation

Meggy Jr RGB Example Code

The main aim of these examples is to help students get started on programming the Meggy Jr RGB. I would encourage people to read through, understand, compile, load, and modify each of the example programs provided. Also the circuit diagram and the library code for arduino development environment are helpful in working out how to control the Meggy (these are available from the link above).

The examples are availalbe from: example downloads.

tone.c

This is the simplest program to get working on the Meggy. It basically involves toggling the pin connected to the speaker at a fixed rate. Don't run it for to long it is very annoying.

lights.c

This changes the lights at the top of the meggy along with one column of the display. The ICs that drive the LEDs are set by serially shifting the values into them. The great thing about the AVR is that this is very simple as once setup the value you wish to shift into the LED drivers can be placed into a register and the AVR does the rest (just poll for this shift to be complete).

screen.c

This extends lights.c by creating a frame buffer and switching between the different columns of the screen to give the appearance of all the LED being on at the same time. I seem to have some error in the code with one column not working. See if you can work out what the problem is!

serialout.c

This shows how character output can be sent via the serial cable. This may be useful for doing some debugging.

keys.c

This shows how input from the keyboard can be obtained. This basically involve looking at values of the accociated pins on the AVR.

interrupt.c

Using interrupts to create a tone.

scribble.c

A simple drawing program. Combines code from screen.c and keys.c to create an interactive program.