The amazing sport action: Rio Olympics 2016 is starting today, but we makers want to enjoy it in some way. So, we wanted to make a Rio Olympics 2016 countdown timer. For this, we need a source for time, a micro controller and a display. For making such timing based stuff running for hours, we cannot rely on Arduino (ATmega) clock as once we switch off the circuit, the time is lost. This is solved using Real Time Clock(RTC), We can use ICs like PCF8563 to accomplish this and for display we will be using the commonly available 1.8" SPI based TFT screen along with Arduino. Evive has all this stuff included in its board. We will not use any SD card to save the logo, but will convert it to array form and store it in Arduino's flash memory. So, not worry much but hardware, and start making this DIY countdown timer.
First we need to see the pinout diagram. We can find this here:
http://evive.cc/files/eviveSchematicPinOutDiagram.png
The TFT screen is connected to SPI pins or Arduino MEGA along with some other pins. RTC is connected to evive using IIC (or I2C) bus via SDA and SCL pins.
Next thing is we need to convert the colored RIO logo into array form from image (.jpg or .png etc). A very detailed tutorial for this can be found here:
http://www.instructables.com/id/Converting-Images-to-Flash-Memory-Iconsimages-for-/
The converted image is them stored in a file, which looks like this:
To print this Colored logo on TFT screen, the Adafruit library does nto have any functions, so we do it pixel wise like this:
// Multi Colored Images/Icons
int h = 66,w = 160, row, col, buffidx=0;
for (row=0; row<h; row++) { // For each scanline...
for (col=0; col<w; col++) { // For each pixel...
//To read from Flash Memory, pgm_read_XXX is required.
//Since image is stored as uint16_t, pgm_read_word is used as it uses 16bit address
tft.drawPixel(col, row, pgm_read_word(olympicsLogo + buffidx));
buffidx++;
} // end pixel
Now we need to workout for the RTC. We can find a detailed tutorial to do that here: http://www.instructables.com/id/Alarm-Clock-With-Evive/
We need to modify and this code and merge the above code snippet to the alarmClock code together.
The final codes can be found here: https://github.com/evivetoolkit/eviveProjects/tree/master/olympicsCountDownTimer/olympicsCountDownTimer
The time is set once only in RTC (PCF8563 IC). It remembers the time as evive has internal battery (Note that Arduino is off, but still the time is continuously running. That's the work of RTCs)
Everything is ready, and lets upload the program in Arduino MEGA of evive.
Comments