Building Hex Files for the Meggy Jr

Getting started with the Meggy Jr on the linux machines in CS department.

  1. Download the MeggyJrSimple.cpp, MeggyJrSimple.h, MeggyJr.cpp, MeggyJr.h, Makefile, PA3Flower.java.s, and simple-test.cpp files.
  2. Plug the Meggy Jr device into your USB port in CompSci 325 or 215.
  3. Follow the directions at the top of the Makefile file to compile the example and install it on your Meggy Jr device.

Use the reference compiler to compile a MeggyJava program

The reference compiler compiles MeggyJava code to AVR assembly, which is what your compilers will be doing as well. It can be helpful to use the reference compiler on your test cases to see what code it generates.

To try out the reference compiler, first download the example input PA5Cylon.java. Then do the following on a linux box in the CS department:

    java -jar ~cs453/public/MJ.jar PA5Cylon.java
This will generate a PA5Cylon.java.s file, which you can then compile and upload to the Meggy Jr using the above provided Makefile.

Things to try out next

Getting started with the Meggy Jr on a Mac (OPTIONAL)

Pretty much following www.evilmadscientist.com/article.php/meggyjrlib. These instructions are offered as is with NO support from the 453 instructor or TA. If you figure out how to get Arduino to work with your Windows or linux box, please consider sharing it with the rest of the class. If you find any errors in the below, please let us know.
  1. Download the Arduino software from http://arduino.cc/en/Main/Software. Copy the Arduino application to the Applications directory.
  2. It is possible that you will need to install a USB serial driver. I did in 2011, but I didn't in 2015.
  3. Make the MeggyJrLibrary accessible in Arduino.
    1. Download MeggyJrLibrary1.40.zip from http://code.google.com/p/meggy-jr-rgb/.
    2. Exit out of Arduino application.
    3. Put the unzipped folder into the Sketchbook location in a subdirectory called libraries, which is specified in the Arduino preferences and is by default /Users/yourusername/Documents/Arduino/. You will probably have to create the libraries subdirectory, /Users/yourusername/Documents/Arduino/libraries/, and place the MeggyJr folder in the libraries/ subdirectory.
    4. Restart the Arduino application.
    5. You should be able to open the MeggyJr examples. For instance, try File->Examples->MeggyJr->MeggyJr_FroggyJr in the Arduino application.
  4. Upload an example to the MeggyJr device.
    1. Under the Tools->Board menu select Arduino Duemilanove or Nano w/ ATmega328
    2. Plug the Meggy Jr device into your USB port, turn it on, and make sure /dev/tty.usbserial-* is selected under Tools-->Serial Port.
    3. Click the upload button on the example. The example should start immediately running on the Meggy Jr device.
  5. Writing your own example in C WITHOUT using the Arduino GUI.
    1. Download the MeggyJrSimple.cpp, MeggyJrSimple.h, MeggyJr.cpp, MeggyJr.h, Makefile.mac, and simple-test.cpp files.
    2. Plug the Meggy Jr device into your USB port, turn it on, and make sure /dev/tty.usbserial-** is selected under Tools-->Serial Port in Arduino (this is all you have to do in the Arduino IDE).
    3. Follow the directions at the top of the Makefile.mac file for the input file simple-test.cpp (so file=simple-test).
    4. Create your own .cpp file by copying the frame.cpp file. The build process in the Makefile.mac is set up for a single .cpp file of any name.

mstrout@cs.colostate.edu .... January 9, 2015