Color Alarm Clock
The Color Alarm Clock is an assistive device aimed to make waking up in the middle of the night easier. The device acts as an ordinary alarm clock with the added twist of a colored LED display, with distinct colors indication the mode of the clock and the time of day. The color coding currently differentiates the time of day so the user can recongize the approximate time of day without needing to read the time. This feature is especially helpful at night as the user can program the clock to display a specific color, currently set as green, to indicate whether the user has more time to sleep or if their alarm is soon to sound.
Video displaying the different functions the alarm clock has, these are listed in detail below.
Nighttime Mode: Green Lights to indicate the ability to continue to sleep
Setting Time Mode: Purple Lights to indicate the ability to adjust the time
Setting Alarm Mode: Red Lights to indicate the ability to set the time the alarm will sound
Progress Photo #1: Hardware Testing
Here was my first time testing the hardware implementation of all the elements together, revealing how each component interacted with the other elements. In addition, the communication between the software and hardware was tested to ensure that the arduino was properly reading and writing data signals. The biggest challenge I faced at this point was getting the speaker and lights to sync for when the alarm was going off. I believe this was because many things had to happen simultaneously and only in a very specific situation. Luckily, I managed to get everything working fairly quickly and was then able to move onto the next stage of my process.
Progress Photo #2: Laser Cutting
Pictured here is an image of a failed attempt for the laser cut box that I intended to place my project into. I believe one of the longest parts of this project was designing and fabricating this box. I came into this project with some knowledge of how to CAD and laser cut, however, the laser cutting skills needed for the tabs on the box tested my abilities and caused me to learn new techniques to be able to create it. The part that I struggled with the most was placement and sizing of the tabs that connect each side of the box to one another. Since the placement had to be very specific, anytime one tab was off or in an incorrect position I found myself needing to update my CAD file and laser cut a new piece. Ultimately, the constant edits I had to make and lack of access to a laser cutter caused the fabrication process to be much longer than expected.
Progress Photo #3: Soldering and Finalizing Physical Implementation
This photo depicts a snippet of the soldering and installation process. My original plan for soldering included many more soldering connections, however, I found that the process of soldering everything would have been too time consuming. For instance, I initially planned on soldering each segment of the seven segment displays separately, then connecting each number display together. Instead, I used one strip of LED lights for each digit, and then soldered those four connections. In addition to the lights, I soldered onto solder boards to connect each of the buttons to their resistors and power/ground/data wires. While the photo does not show the solder boards, it does show all the hardware being placed into the final box. This includes the three breadboards and arduino, and all the cables connected between the two.
Progress Photo #4: LED Number Display
The last task I completed to finish the project was implementing the timer display and LED colors. The color changing aspect of this project was much easier than I expected it to be, as it ended up involving only a few if-else statements in my code. On the other hand, the timer display was unfortunately harder than I had anticipated. Since I changed my implementation plan on the LED strips, my code for the numbers no longer corresponded to the correct address of each LED. Additionally, since the LEDs were no longer back-to-back as I had planned, the code portion became much lengthier as I could no longer loop through the array indexes but rather had to hand-program each light. Fortunately, I had programmed number displays similar to this before so figuring out which segment should be on/off was simple. However, I am mildly disappointed I was unable to condense my code more.
Response
Overall I really enjoyed this project and all that it taught me. I am happy with how my project came out as everything worked as intended, the only part I am disappointed in is that it broke right as I began presenting at the critique. Ultimately though, seeing the project work correctly at least for a portion of time was very rewarding, and I know a few others were able to see it work before it broke as evident from the feedback.
The most influential part of the project was the learning curve for time management and estimating how long each step of the project will take. For instance, I had originally planned on getting the physical fabrication of the project completed way sooner but found that laser cutting the enclosure for all the components took much longer than I anticipated. Since I understand more about the progress and which steps I should take when I am hoping all my following projects will go much smoother. Additionally, while I knew how to solder before attempting this assignment, the soldering required for this project taught me better soldering methods and allowed me to practice soldering.
In the future if I had to recreate this project there would be few things I would change. The biggest attribute I would change is making the buttons on top of the clock raised above the surface more to make interacting with those buttons easier. Additionally, I would secure the soldering boards the buttons rested on to the inside of the casing better as I suspect that that was part of the reason my internal wiring broke during the critique. Aside from those few things I would avoid changing the fabrication of my design as I got multiple comments on the sleek and straightforward design.
Block Diagram
Schematic
//Project 2 Color Alarm Clock (9/26/23)
//By Kira Lentz
/*
This file includes all the code needed to create a personalized,
color-changing alarm clock. The hardware aspect of the alarm clock
includes 3 switches, 3 buttons, and a speaker. The switches control
the function the user is interacting with, an example of this is
the setting alarm and setting time switches. When on, these switches
will display a unique color to indicate the mode and will allow the
user to changing either the current time or alarm time, respecitively.
The third and final switch controls whether an alarm is set on not,
this depicts if the speaker will sound or not. When enabled, the speaker
will sound when the current time is equal to the set alarm time. The
sound of the speaker can be turned off with the snooze button, which is
one of three buttons. The other two buttons pertain to changing the hour
and minutes of the time. They are used for both setting the alarm and
setting the time. By pressing either the hour or minute button the
respecitive time will increase by one. The time is set on a 24-hour
time, so when the clock reads 23:59, it will set back to 00:00, as
excepted with 24 hour time. A unique part of this project is the
color changing capablities of the display. The specific colors can
be changed but are currently set to the following, daytime: blue,
nighttime: green, setting alarm: red, setting time: red,
alarm going off/sounding: red.
Pinouts for each Input
13 : LED Data Pin
6 : Alarm Switch
7 : Set Time
8 : Set Alarm
9 : Hour Button
10 : Minute Button
11 : Snooze Button
5 : Speaker pin
*/
#include "FastLED.h"
//For LEDs
#define DATA_PIN 13
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
#define NUM_LEDS 100
#define BRIGHTNESS 255
CRGB LED[NUM_LEDS];
const int hourTensLed = 0;
const int hourOnesLed = 25;//24?
const int minTensLed = 50;
const int minOnesLed = 75;
//For switches
const int ALARM_SWITCH = 6;
const int SET_TIME = 8;
const int SET_ALARM = 7;
//For buttons
const int HOUR = 9;
const int MINUTE = 10;
const int SNOOZE = 11;
//For Speaker
const int SPEAKER_PIN = 5;
const int FREQ = 170;
//For time
unsigned long minute_pause = 3000;//60000; //One minute pause for display update
unsigned long timer = 0;
int hour = 0; //0-24
int min = 0; //0-59
int alarmHour = 23;
int alarmMin = 59;
// int bedtimeHour = 22;
// int bedtimeMin = 0;
//Led Colors
CRGB colorLed;
CRGB RED = CRGB(255,0,0); //Setting Alarm, alarm going off
CRGB GREEN = CRGB(0,255,0);
CRGB BLUE = CRGB(0,0,255);
CRGB PURPLE = CRGB(255,0,255);
// const int YELLOW = 0xffcc66; //30 Minutes before Alarm goes off
// const int PURPLE = 0x990099; //Setting the time
//Misc.
bool alarmSet = true;
bool speakerMakeNoise = false;
int timeButtonDelay = 1000;
void setup(){
pinMode(ALARM_SWITCH, INPUT); //High = speaker will turn on, LOW = off, no sound
pinMode(SET_TIME, INPUT); //High = change time
pinMode(SET_ALARM, INPUT); //High = change alarm
pinMode(HOUR, INPUT); //Button to change the hour
pinMode(MINUTE, INPUT); //Button to change the minutes
// pinMode(SPEAKER_PIN, OUTPUT);
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(LED, NUM_LEDS)
.setCorrection(TypicalLEDStrip)
.setDither(BRIGHTNESS < 255);
Serial.begin(9600); //Change baud
}
void display_number(int number, int start){
// Serial.print("Number to display: ");
// Serial.println(number);
// Serial.print("LED Start index: ");
// Serial.println(start);
Serial.println(number);
for(int r = start; r <= start+24; r++){
LED[r] = CRGB::Black;
}
if(number == 1){
LED[start+8] = colorLed;
LED[start+9] = colorLed;
LED[start+11] = colorLed;
LED[start+12] = colorLed;
} else if(number == 2){
LED[start+4] = colorLed;
LED[start+5] = colorLed;
LED[start+0] = colorLed;
LED[start+1] = colorLed;
LED[start+24] = colorLed;
LED[start+23] = colorLed;
LED[start+11] = colorLed;
LED[start+12] = colorLed;
LED[start+15] = colorLed;
LED[start+16] = colorLed;
if(start == minOnesLed) LED[start+22] = colorLed;
} else if(number == 3){
LED[start+4] = colorLed;
LED[start+5] = colorLed;
LED[start+8] = colorLed;
LED[start+9] = colorLed;
LED[start+11] = colorLed;
LED[start+12] = colorLed;
LED[start+15] = colorLed;
LED[start+16] = colorLed;
LED[start+23] = colorLed;
LED[start+24] = colorLed;
if(start == minOnesLed) LED[start+22] = colorLed;
} else if(number == 4){
LED[start+20] = colorLed;
LED[start+19] = colorLed;
LED[start+8] = colorLed;
LED[start+9] = colorLed;
LED[start+11] = colorLed;
LED[start+12] = colorLed;
LED[start+23] = colorLed;
LED[start+24] = colorLed;
if(start == minOnesLed) LED[start+22] = colorLed;
} else if(number == 5){
LED[start+9] = colorLed;
LED[start+8] = colorLed;
LED[start+4] = colorLed;
LED[start+5] = colorLed;
LED[start+23] = colorLed;
LED[start+24] = colorLed;
LED[start+19] = colorLed;
LED[start+20] = colorLed;
LED[start+15] = colorLed;
LED[start+16] = colorLed;
if(start == minOnesLed) LED[start+22] = colorLed;
} else if(number == 6){
LED[start+9] = colorLed;
LED[start+8] = colorLed;
LED[start+4] = colorLed;
LED[start+5] = colorLed;
LED[start+23] = colorLed;
LED[start+24] = colorLed;
LED[start+19] = colorLed;
LED[start+20] = colorLed;
LED[start+15] = colorLed;
LED[start+16] = colorLed;
LED[start] = colorLed;
LED[start+1] = colorLed;
if(start == minOnesLed) LED[start+22] = colorLed;
} else if(number == 7){
LED[start+15] = colorLed;
LED[start+16] = colorLed;
LED[start+8] = colorLed;
LED[start+9] = colorLed;
LED[start+11] = colorLed;
LED[start+12] = colorLed;
} else if(number == 8){
LED[start] = colorLed;
LED[start+1] = colorLed;
LED[start+4] = colorLed;
LED[start+5] = colorLed;
LED[start+8] = colorLed;
LED[start+9] = colorLed;
LED[start+11] = colorLed;
LED[start+12] = colorLed;
LED[start+15] = colorLed;
LED[start+16] = colorLed;
LED[start+19] = colorLed;
LED[start+20] = colorLed;
LED[start+23] = colorLed;
LED[start+24] = colorLed;
if(start == minOnesLed) LED[start+22] = colorLed;
} else if(number == 9){
LED[start+19] = colorLed;
LED[start+20] = colorLed;
LED[start+8] = colorLed;
LED[start+9] = colorLed;
LED[start+11] = colorLed;
LED[start+12] = colorLed;
LED[start+23] = colorLed;
LED[start+24] = colorLed;
LED[start+15] = colorLed;
LED[start+16] = colorLed;
if(start == minOnesLed) LED[start+22] = colorLed;
} else {
LED[start] = colorLed;
LED[start+1] = colorLed;
LED[start+4] = colorLed;
LED[start+5] = colorLed;
LED[start+8] = colorLed;
LED[start+9] = colorLed;
LED[start+11] = colorLed;
LED[start+12] = colorLed;
LED[start+15] = colorLed;
LED[start+16] = colorLed;
LED[start+19] = colorLed;
LED[start+20] = colorLed;
}
}
int get_time(){
if(min < 59) {
min++;
} else {
//Currently 24 hour time
if(hour == 23) {
hour = 0;
} else{
hour++;
}
min = 0;
}
return hour*100 + min;
}
void display_time(){
get_time();
//COMMENT
Serial.print("The time is ");
Serial.print(hour/10);
Serial.print(hour%10);
Serial.print(":");
Serial.print(min/10);
Serial.println(min%10);
//HERE
display_number(hour/10, hourTensLed);
display_number(hour%10, hourOnesLed);
display_number(min/10, minTensLed);
display_number(min%10, minOnesLed);
}
void change_alarm(){
if(digitalRead(HOUR)){
alarmHour++;
if(alarmHour == 24){
alarmHour = 0;
}
}
if(digitalRead(MINUTE)){
alarmMin++;
if(alarmMin == 60){
alarmMin = 0;
}
}
delay(400);
//COMMENT
Serial.print("Hour: ");
Serial.print(alarmHour);
Serial.print(" Min: ");
Serial.println(alarmMin);
//COMMENT
display_number(alarmHour/10, hourTensLed);
display_number(alarmHour%10, hourOnesLed);
display_number(alarmMin/10, minTensLed);
display_number(alarmMin%10, minOnesLed);
}
void change_time(){
//If hour is being depressed, count
if(digitalRead(HOUR)){
hour++;
if(hour == 24){
hour = 0;
}
}
if(digitalRead(MINUTE)){
min++;
if(min == 60){
min = 0;
}
}
delay(400);
Serial.print("Hour: ");
Serial.print(hour);
Serial.print(" Min: ");
Serial.println(min);
display_number(hour/10, hourTensLed);
display_number(hour%10, hourOnesLed);
display_number(min/10, minTensLed);
display_number(min%10, minOnesLed);
}
void loop(){
//Update the clock every minute
if(millis() - timer > minute_pause){
display_time();
//FastLED.show();
timer = millis();
}
//Setting the time the alarm should go off at
if(digitalRead(SET_ALARM)){
Serial.println("Setting ALARM");
colorLed = RED;
change_alarm();
}
//Setting Time
else if(digitalRead(SET_TIME)){
Serial.println("Setting TIME");
colorLed = PURPLE;
change_time();
timer = millis();
}
//If there alarm switch is on, indicating the want for the alarm to sound
else if(digitalRead(ALARM_SWITCH) && hour == alarmHour && min == alarmMin){
//Checking if its the correct time for the alarm to sound
//makeSound
// colorLed = red;
speakerMakeNoise = true;
colorLed = RED;
Serial.println("ALARM GOING OFF");
Serial.print("Hour ");
Serial.print(hour);
Serial.print(" AlarmHour ");
Serial.print(alarmHour);
Serial.print(" Min ");
Serial.print(min);
Serial.print(" AlarmMin ");
Serial.println(alarmMin);
} else if(colorLed != BLUE){
colorLed = GREEN;
}
//If the snooze button has been pressed,
//change color to blue and turn off speaker
if(digitalRead(SNOOZE)){
speakerMakeNoise = false;
colorLed = BLUE;
noTone(SPEAKER_PIN);
}
//If snooze has not yet been pressed,
//the speaker shall continue to play a sound
else if(speakerMakeNoise){
//make the speaker make noise still
tone(SPEAKER_PIN, FREQ);
colorLed = RED;
Serial.println("SPEAKER GOING OFF");
}
//Change time
//Change alarm
//Change hours
//Change minutes
//Display time
//Update timer
//Play sound
// for(int i = 0; i < 7; i++){
// hourTensLed[i] = colorLed;
// }
FastLED.show();
}