![]() |
|
![]() |
![]() |
By | No Comments | on May 31, 2010 7:06 AM![]() |
![]() |
![]() ![]()
The day after I got home from the Maker Faire, I immediately began messing with the board to see what I could do with it. A simple test revealed that it did not have the Arduino boot-loader installed, no surprise there.
![]() I used the boot-loader to flash the original Simon firmware back on the board and ran into the first big problem. The game ran too fast by a factor of eight with the stock firmware from SparkFun. I remembered reading something in the AVR features that allowed the speed of the chip to be changed at runtime. I did a little research to find some code that showed how to use the prescaler and set it to divide by 8. After a recompile and upload, the game worked at the correct speed. As I wasn't able to establish an accurate reuse permission from the code, I am offering just a diff file of my changes against Sparkfun's original code. This diff file was produced with the command-line diff utility. Just apply it to the Simon-v21.c source file and run make. The patcher complains about something, but the file still works after. The makefile still builds the source for the ATmega168, but that is just the smaller version of the ATmega328 and the less changed the better. With the clock speed issue solved I was able to continue and add more than cursory support to the Arduino IDE for this board. I originally modified the Arduino core and all of its supporting files to include my changes, but I realized how much a pain it would be to install and update if the IDE changes. I read the instructions for adding new hardware to the IDE and created the proper subdirectories within my Arduino folder to use the board without modification to the core. I also created a library the has wrapper functions that have the pin coded into them to avoid re-looking up the pin assignment every-time you use the board. I also overloaded the tone function in the library to just use the frequency argument and omit a pin. This function sets up the onboard buzzer and then calls tone. A call to noTone(); then disables the tone again. Using blue for an example here: blue(LOW|HIGH) // turns off or on the blue LED, while readBlue() // returns the state of the blue button. The acual code that implements these functions is below: Going back to the original simon firmware again. Since we have gone to all of this effort to set up the Simonduino, we don't want to ISP program the original Simon game back over the boot-loader. The correct avrdude command for programming the Simon firware back in the board is:
avrdude -p m328p -c avrisp -P /dev/cu.usbserial-FTDI-3.3 -b 19200 -F -U flash:w:"Simon-v21.hex" This command does the same thing as the Arduino boot-loader sans the fancy gui. ![]() The last modification I made to the board was hardware. I soldered a six pin right angle header to the board that allows me to connect my FTDI Basic to the board rather than angling its pins against the board as a long term solution. The header was soldered on in such a way that it did not stick up into the button pad and faced inwards over the board. This header is compatible with the FTDI cable but the reset may not work, I have not tested it. My files and modifications are available for download below. I do not really care what you do with this code as long as you respect the original licenses of the modified code. The boot-loader source code and makefile (modified): Simon_Bootloader.zip. Unless you plan on modifying the boot-loader, you don't need this. The Simon library (written by me): Simon_Lib.zip. This goes in the libraries subfolder of your sketchbook. The Simon hardware spec for Arduino IDE: simon_Hardware.zip. This provides the board entry, build settings, and boot-loader for the IDE. This goes in the hardware subdirectory of your sketchbook.
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
![]() |
![]() |
|
![]() |
![]() |
![]() |
![]() |
![]() |