Skip to content

Programming the arduino

ccachin edited this page Apr 23, 2017 · 5 revisions

The wordclock is powered by an arduino nano. We choose the nano because of the price and the small form factor.

Prerequisites

  • To compile and upload the code you will need the Arduino IDE. You can download it directly from the Arduino website : https://www.arduino.cc/en/Main/Software

  • (Optional) If you want to edit the code, a simple text editor will be enough but I recommend to use Atom.io (free) or any other C++ editor so you have a minimum of code highlight.

Getting the code

You can either clone the github repository if you're familiar with git or you can simply download an archive of the repos.

Compiling and editing the code

  • Connect the arduino using an USB cable.

  • Open the file software/wordclock/wordclock.ino with the Arduino IDE.

  • Select the board Arduino nano (see screenshot below). If the board is not available, use the Board manager to download it. Board selection

  • Select the processor ATmega328

  • Select the good COM port (sometimes the name of the board will be display next to the COM port number, if not, it's not really an issue)

  • Click on the "arrow right* icon (upload). This will compile then upload the code on your arduino board. Board selection

Layout (language)

Changing the layout

By default the layout is in french. But maybe you're using a different language or you have made a custom layout. The layout files that we provide are in the folder software/wordclock/layouts. If you want to change the language to english for example just uncomment your language in constant.h as below:

//#define LAYOUT_DE
//#define LAYOUT_FR
#define LAYOUT_EN

Customize the layout

If you open the layout.cpp file you can see how it works. Each led has a number (the first one is 0). The leds are arranged in a snake shape. The beginning is at the top left corner. See the first two line for you will quickly understand.

|000|001|002|003|004|005|006|007|008|009|010|011|
|023|022|021|020|019|018|017|016|015|014|013|012|
|024|   |   |   |   |   |   |   |   |   |   |035|
|047|   |   |   |   |   |   |   |   |   |   |036|
|048|   |   |   |   |   |   |   |   |   |   |059|
|071|   |   |   |   |   |   |   |   |   |   |060|
|072|   |   |   |   |   |   |   |   |   |   |083|
|095|   |   |   |   |   |   |   |   |   |   |084|
|096|   |   |   |   |   |   |   |   |   |   |107|
|119|   |   |   |   |   |   |   |   |   |   |108|
|120|   |   |   |   |   |   |   |   |   |   |131|
|143|   |   |   |   |   |   |   |   |   |   |132|

If you want to customize the layout, just edit the method

void Layout::getLayout(char hour, char minute, char sec, Display* d) 

By default all leds are off, you just have to indicate which led you want to power on.

Clone this wiki locally