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
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-KL25Z | MI0283QT-9A |
---|---|
P3V3 | 3.3V, IM1, IM2, IM3 |
GND | RD, IM0, LEDK |
PTD5 | CS |
PTD1 | RS |
PTD0 | RST |
PTD2 | SDI |
PTD3 | SDO |
PTA13 | WR |
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-KL25Z | Input |
---|---|
PTA5 | Minute button |
PTC8 | Hour button |
PTC9 | Time 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)
Diff: main.cpp
- Revision:
- 8:6bd70a8697f4
- Parent:
- 7:007d23438920
- Child:
- 9:d34cdff0205c
diff -r 007d23438920 -r 6bd70a8697f4 main.cpp --- a/main.cpp Fri May 26 09:48:57 2017 +0000 +++ b/main.cpp Fri May 26 10:03:27 2017 +0000 @@ -90,6 +90,8 @@ TFT.background(Black); // Set background to black TFT.set_font((unsigned char*) Arial28x28); // Set the font to Arial 28x28 + TFT.locate(30, 70); // Move the text location + TFT.printf("Time:"); // Display some text timer.attach(&timeup, 1); // Set up the timer so it increments every second @@ -146,18 +148,20 @@ { alarm_minutes += 5; // Add 5 minutes (snooze) } - if (clock_hours == alarm_hours && clock_minutes == alarm_minutes && (clock_seconds % 2) == 0 && enable) // Check if the time is equal to the alarm time, and the seconds is even + if (clock_hours == alarm_hours && clock_minutes == alarm_minutes && enable) // Check if the time is equal to the alarm time, and the seconds is even { buzzer = 1; // Buzz - + wait(0.2); // Wait + buzzer = 0; // Don't buzz + wait(0.2); // Wait } else { buzzer = 0; // Don't buzz } TFT.foreground(White); // Set text to white - TFT.locate(30, 70); // Move the text location - TFT.printf("Time: %02d:%02d.%02d", clock_hours, clock_minutes, clock_seconds); // Write the time to the TFT + TFT.locate(120, 70); // Move the text location + TFT.printf("%02d:%02d.%02d", clock_hours, clock_minutes, clock_seconds); // Write the time to the TFT if (enable){ // Check if the alarm is enabled TFT.foreground(Green); // Write the alarm text in green