Final version, with changing analogue clock colours, Friday 11:20am

Dependencies:   MMA8451Q SPI_TFT_ILI9341 TFT_fonts mbed

Smart clock by Duncan and Kieran

Photo

http://www.imgur.com/SiyOshx.jpg

Equipment

  • PCB: FRDM-KL25Z
  • TFT Color Display: MI0283QT-9A
  • Buzzer
  • 3 x buttons
  • 3 x 2kΩ resistors and 1 x 100Ω resistor
  • Stripboard
  • Wires (stranded is preferable due to their flexibility)
  • USB to Mini-USB cable, and computer

Setup

PCB to TFT (Output)

FRDM-KL25ZMI0283QT-9A
P3V33.3V, IM1, IM2, IM3
GNDRD, IM0, LEDK
PTD5CS
PTD1RS
PTD0RST
PTD2SDI
PTD3SDO
PTA13WR
P5V_USB through 100Ω resistor (approx. 20mA)LEDA

The buzzer should be connected between PTA12 and ground.

Note: The resistance between P5V_USB and LEDA can be reduced to increase the brightness of the screen. However, resistors lower than 30Ω have not been tested, and may result in the current causing damage to the PCB.

PCB to Buttons (Inputs)

FRDM-KL25ZInput
PTA5Minute button
PTC8Hour button
PTC9Time change button - toggles between changing the alarm time and the clock time

Each button should be connected in series with a 2kΩ resistor between 3.3V and 0V, so that pressing the button switches between these two voltages.

Features

  • A digital clock, displayed in 24-hour format
  • An analogue clock, displaying the time in standard 12-hour format
  • Alarm can be changed using the minute and hour buttons
  • Time can be changed by holding the third button
  • Alarm will sound for one minute at the displayed time
  • Putting the alarm on its side will snooze the alarm if the alarm is going off (or just disable it if the alarm is not sounding)
Committer:
scat6490
Date:
Tue May 23 14:45:54 2017 +0000
Revision:
0:4fd6c8718206
Child:
1:a33f6ca5a5b3
Working display (Tuesday 3:45pm)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
scat6490 0:4fd6c8718206 1
scat6490 0:4fd6c8718206 2 #include "stdio.h"
scat6490 0:4fd6c8718206 3 #include "mbed.h"
scat6490 0:4fd6c8718206 4 #include "SPI_TFT_ILI9341.h"
scat6490 0:4fd6c8718206 5 #include "string"
scat6490 0:4fd6c8718206 6 #include "Arial12x12.h"
scat6490 0:4fd6c8718206 7 #include "Arial24x23.h"
scat6490 0:4fd6c8718206 8 #include "Arial28x28.h"
scat6490 0:4fd6c8718206 9 #include "font_big.h"
scat6490 0:4fd6c8718206 10
scat6490 0:4fd6c8718206 11 SPI_TFT_ILI9341 TFT(PTD2, PTD3, PTD1, PTD5, PTD0, PTA13,"TFT"); // mosi, miso, sclk, cs, reset, dc for frdmkl25z
scat6490 0:4fd6c8718206 12
scat6490 0:4fd6c8718206 13 int main()
scat6490 0:4fd6c8718206 14 {
scat6490 0:4fd6c8718206 15 //pc.baud(115200);
scat6490 0:4fd6c8718206 16 wait(0.2);
scat6490 0:4fd6c8718206 17
scat6490 0:4fd6c8718206 18 TFT.set_orientation(1); // Make it horizontal
scat6490 0:4fd6c8718206 19 TFT.background(Red); // Set background to black
scat6490 0:4fd6c8718206 20 TFT.foreground(White); // Set text to white
scat6490 0:4fd6c8718206 21 TFT.cls(); // Clear screen
scat6490 0:4fd6c8718206 22 TFT.set_font((unsigned char*) Arial12x12); // Set the font
scat6490 0:4fd6c8718206 23
scat6490 0:4fd6c8718206 24 TFT.fillrect(0, 0, 320, 30, Red);
scat6490 0:4fd6c8718206 25 TFT.printf("Clock by Duncan and Kieran");
scat6490 0:4fd6c8718206 26
scat6490 0:4fd6c8718206 27 wait(0.1);
scat6490 0:4fd6c8718206 28
scat6490 0:4fd6c8718206 29 TFT.background(Black); // Set background to black
scat6490 0:4fd6c8718206 30 TFT.set_font((unsigned char*) Arial28x28); // Set the font
scat6490 0:4fd6c8718206 31
scat6490 0:4fd6c8718206 32 for(int i=0; i<10; i++) {
scat6490 0:4fd6c8718206 33 wait(1); // Wait 1 second
scat6490 0:4fd6c8718206 34 TFT.locate(50,50); // Move location
scat6490 0:4fd6c8718206 35 TFT.printf("Time: %d",i); // Write text
scat6490 0:4fd6c8718206 36 }
scat6490 0:4fd6c8718206 37
scat6490 0:4fd6c8718206 38 }