Many people write me asking if it would be possible to add/modify the clock color palettes or change the lamp mode display. Of course it is possible, it’s open source! OK but, what does it mean for a clock to be open source? Why would you care?
The short answer is, being open source gives you, the user, full control on the product. You can open it, hack it, repair it … it’s your’s! You can make your own Fibonacci Clock if you want. The only restriction is that you have to give attribution to the creator of the project if you publish your hack.
Making this project open also mean I want to ear about your hacks! The more we share our modifications and hacks, the better the product get over time. Post your modifications on Github or social media so we can benefit from your work.
In this short article I’ll guide you step by step on how to hack the clock code.
The Fibonacci Clock program is running in an Atmega328 micro-controller running the Arduino boot-loader. The micro-controller is an integrated circuit that act as a small computer. Among other things, the micro-controller is responsible for reading physical sensors and inputs as well as controlling hardware devices like LEDs and motors.
While the micro-controller can be referred to as a small computer, the boot-loader could be compared to the computer operating system. The Arduino boot-loader is an open source software designed specifically to run on an Atmega micro-controller.
To upload the clock software on the micro-controller you’ll need to use the Arduino programming tools. These tools includes the code editor, the compiler and the program to upload your compiled code. These tools are the subject of the next section.
The Arduino programming tools are open source and available for Windows, Linux and Mac. Start by downloading the software for your Operating System on the Arduino website at https://www.arduino.cc/en/Main/Software and follow the installation instructions. In addition to the programming tools, this will install the USB to serial drivers you need to communicate with the Arduino micro-controller.
Code Editor (IDE)
Starting the Arduino application you’ll get this screen. This is the Arduino IDE. It offers a code editor, a compiler and the software to communicate with the micro-controller.
I’ll skip the basics of a code editor to focus on the two first icons in the toolbar of the application. The first one starts the compiler. Arduino will then convert your C/C++ code into a compiled code the micro-controller understands. If there is a compilation error, the compiler aborts and report the code error in the black message window at the bottom of the screen.
If the compilation succeeded with no error, you can upload your code to the micro-controller by clicking the second icon in the toolbar of the application but, before you upload your code you need to do some configurations so that the IDE knows how to communicate with the micro-controller.
Setting board type
There are several different variations of Arduino boards on the market. the one I am using in the clock is the Arduino Uno. In order to communicate with it, you must set the board type in the IDE to “Arduino Uno”.
Set the serial port
The IDE on your computer communicates with the micro-controller through a serial connection established on top of the USB protocol. When you connect the Arduino board or, in our case the Fibonacci Clock board to the computer, a new Serial port will be created. Select this serial port to communicate with the clock.On Linux and Mac the serial port is named differently.
Connecting the Fibonacci Clock
To connect the Fibonacci Clock board to the computer you have two choices. Your first choice is to use an FTDI cable with a USB connector on one end and a female header connector on the other. This cable includes the FTDI chip that handle the conversion USB-Serial.
The other solution would be to use a standard USB cable connected to an FTDI breakout board. In this scenario, the FTDI chip is on the breakout board and can be used with any USB cable.
When you connect the Fibonacci Clock board to the computer, make sure you connect the ground (Gnd, Blk) pin on the side identified on the board with the “BLK” label. You are now ready to upload your code to the clock.
Loading/Editing The Fibonacci Clock Code
Arduino projects are all, by default, located in a specific directory. You can get the location of the project folder by navigating to File>Preferences… in your Arduino IDE. The first edit box on top of the dialog is where you should create a folder named fibonacci.
You will find the Arduino code for the clock on my Github account. All the code is in the fibonacci.ino file. Download this file and place it in the fibonacci folder you just created. To load the file in the IDE click File>Open and select the fibonacci project folder.
To compile the project you’ll need an extra library from Adafruit Industries called Adafruit_NeoPixel. You can download the file from the Adafruit Github account with detailed instructions on how to install it on your computer.
You can now make your modifications to the clock code and compile it. The compiler will return an error message if your code is not right. Start by doing some minor changes like colors to learn the process.
Uploading to the clock
Once you have modified and compiled the code with success, you have to upload it to the clock micro-controller to see the result. When using a standard Arduino board all you have to do is press the upload button “et voilà”. With the Fibonacci Clock circuit there is a tiny extra step.
Immediately after you press the IDE upload button, the yellow LED on the board will start flashing. This is the signal to press the reset button on the clock circuit board. This restart the Arduino bootloader and set it in programming mode.
Wait for the code to upload. When finished the IDE will display the “Done uploading”. You’re good to go … your new code is running in your clock! If you get an error message when uploading, make sure the serial port and the board type are set correctly.
Share Your Code
I will post more articles on things you can do with your clock. Don’t miss it by registering to my mailing list! I would love to have you aboard! If you read this article before January 30th 2016 you could win one of three Fibonacci Clocks by subscribing to my newsletter!