Alarm Clock
![IMG_8946.JPG](/proxy/?url=https://content.instructables.com/FSE/UD1D/JO2S8EHY/FSEUD1DJO2S8EHY.jpg&filename=IMG_8946.JPG)
Hey! Do you want to learn how to create your very own alarm clock? Follow this step-by-step tutorial and you'll be able to do it easily. Have fun!
Obs.: This project was based on the alarm clock of the website "Mundo Projetado". Although, me and my group had to make some improvements. Here is the link to the original project: http://mundoprojetado.com.br/despertador-usando-o....
Materials
![IMG_8948.JPG](/proxy/?url=https://content.instructables.com/FQ2/555E/JO2S8N30/FQ2555EJO2S8N30.jpg&filename=IMG_8948.JPG)
![IMG_1315.JPG](/proxy/?url=https://content.instructables.com/FC4/L8S5/JO2S8N0B/FC4L8S5JO2S8N0B.jpg&filename=IMG_1315.JPG)
![IMG_1326.JPG](/proxy/?url=https://content.instructables.com/F6O/HT81/JO2S8N47/F6OHT81JO2S8N47.jpg&filename=IMG_1326.JPG)
![IMG_1313.JPG](/proxy/?url=https://content.instructables.com/FLY/SLI1/JO2S8N05/FLYSLI1JO2S8N05.jpg&filename=IMG_1313.JPG)
![IMG_9043.JPG](/proxy/?url=https://content.instructables.com/FRS/TG5J/JO4NI4DX/FRSTG5JJO4NI4DX.jpg&filename=IMG_9043.JPG)
![IMG_9044.JPG](/proxy/?url=https://content.instructables.com/FPI/E5BS/JO4NI4EG/FPIE5BSJO4NI4EG.jpg&filename=IMG_9044.JPG)
![IMG_1312.JPG](/proxy/?url=https://content.instructables.com/FS3/PTDC/JO2S8MZU/FS3PTDCJO2S8MZU.jpg&filename=IMG_1312.JPG)
![IMG_9054.JPG](/proxy/?url=https://content.instructables.com/FJ1/X5J6/JO4NI530/FJ1X5J6JO4NI530.jpg&filename=IMG_9054.JPG)
![IMG_1319.JPG](/proxy/?url=https://content.instructables.com/F4D/FPOH/JO4NDZ9F/F4DFPOHJO4NDZ9F.jpg&filename=IMG_1319.JPG)
![IMG_1320.JPG](/proxy/?url=https://content.instructables.com/FEV/10MY/JO4NDZ9G/FEV10MYJO4NDZ9G.jpg&filename=IMG_1320.JPG)
![IMG_1321.JPG](/proxy/?url=https://content.instructables.com/FAT/6FQF/JO4NDZ9I/FAT6FQFJO4NDZ9I.jpg&filename=IMG_1321.JPG)
![IMG_1322.JPG](/proxy/?url=https://content.instructables.com/FMQ/1WJO/JO4NDZ9J/FMQ1WJOJO4NDZ9J.jpg&filename=IMG_1322.JPG)
![IMG_1323.JPG](/proxy/?url=https://content.instructables.com/F5R/8M4C/JO4NDZ9K/F5R8M4CJO4NDZ9K.jpg&filename=IMG_1323.JPG)
![IMG_1324.JPG](/proxy/?url=https://content.instructables.com/FZ4/XI03/JO4NDZ9L/FZ4XI03JO4NDZ9L.jpg&filename=IMG_1324.JPG)
![IMG_1325.JPG](/proxy/?url=https://content.instructables.com/FHQ/1VIE/JO4NDZ9M/FHQ1VIEJO4NDZ9M.jpg&filename=IMG_1325.JPG)
![IMG_1314.JPG](/proxy/?url=https://content.instructables.com/FH6/FXEU/JO2S8N09/FH6FXEUJO2S8N09.jpg&filename=IMG_1314.JPG)
To build the alarm clock, you'll need:
- 1 computer;
- 5 buttons;
- 1 display;
- 1 arduino;
- 1 buzzer;
- 1 potentiometer;
- 1 USB cable;
- 1 breadboard;
- 7 resistors - their values must be 100, 300, 500, 700, 900, 1.1 k, 1.3 k or close;
- 22 male-male jumper wires.
Build Circuit 1
![circuito-lcd.png](/proxy/?url=https://content.instructables.com/FXP/UF9W/JO2S8GTU/FXPUF9WJO2S8GTU.png&filename=circuito-lcd.png)
To build circuit 1, you'll need the display, the arduino, the potentiometer, 15 of the jumper wires and one of the resistors.
Follow the image and you should succeed!
Build Circuit 2
![IMG_8951.JPG](/proxy/?url=https://content.instructables.com/FJR/QFQ0/JO2S8ELC/FJRQFQ0JO2S8ELC.jpg&filename=IMG_8951.JPG)
To build circuit 2, you'll need all of the buttons, five of the jumper wires and the six remaining resistors.
Follow the image and you should succeed!
Build Circuit 3
![IMG_9052.JPG](/proxy/?url=https://content.instructables.com/F40/JCSS/JO4NI4ET/F40JCSSJO4NI4ET.jpg&filename=IMG_9052.JPG)
![IMG_8956.JPG](/proxy/?url=https://content.instructables.com/FWL/LM7K/JO2S8EMZ/FWLLM7KJO2S8EMZ.jpg&filename=IMG_8956.JPG)
To build circuit 3, you'll need the buzzer, the arduino and the two remaining jumper wires.
Follow the images and you should succeed!
The Code
![Arduino_ide.jpg](/proxy/?url=https://content.instructables.com/F6E/9GWI/JO2S8I84/F6E9GWIJO2S8I84.jpg&filename=Arduino_ide.jpg)
![IMG_8947.JPG](/proxy/?url=https://content.instructables.com/FZL/RMLH/JO2S8EIB/FZLRMLHJO2S8EIB.jpg&filename=IMG_8947.JPG)
![IMG_8957.JPG](/proxy/?url=https://content.instructables.com/FPT/6ARN/JO2S8ENB/FPT6ARNJO2S8ENB.jpg&filename=IMG_8957.JPG)
![IMG_8955.JPG](/proxy/?url=https://content.instructables.com/FKU/RNVT/JO2S8EMX/FKURNVTJO2S8EMX.jpg&filename=IMG_8955.JPG)
First, you need to download the Arduino app (https://www.arduino.cc/en/Main/Software) and TimeLib (https://playground.arduino.cc/Code/Time). Then, you can copy and paste the code below in a new document in the Arduino app. Don't forget to upload the code!
Important: before you upload the code, don't forget to:
- Check if you put the jumper wires in the right places of the arduino;
- Connect the arduino to the computer.
#include <timelib.h><br></timelib.h>
#include <liquidcrystal.h> LiquidCrystal lcd(12,11, 5, 4, 3, 2); // inicializa a biblioteca do display com os pinos de interface</liquidcrystal.h>
byte setaC[8] = { // simbolo da setinha na configuraçao B00100, B00100, B01110, B10101, B00100, B00100, B00100, B00100, };
byte relogio[8] = { // simbolo do relogio B00000, B10001, B01110, B10101, B10111, B10001, B01110, B00000, };
// Variaveis----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- String menu[3] = {"Mostrar horas", "Definir alarme", "Mudar as horas"}; // Frases do menu char selec = 0; // Variavel do menu principal int alarme[2] = {06, 00}; // Variavel do alarme bool telap = true, telaa = false, telah = false, telac = false, espera = false, ativado = true; // Variaveis de controle das telas
//Musica do despertador------------------------------------------------------------------------------------------------------------------------------------------------------------------ char* musica[] = {"Re", "Mi", "Fa", "Sol", "Do", "La", "Fa", "Do", "Fim"}; //Game of Thrones int duracao[] = {500, 500, 500, 500, 500, 500, 500, 500}; void tocar(char* mus[], int tempo[]); int buz = 10; // Pino do Buzzer
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void setup() { // LIQUIDCRYSTAL lcd.createChar(2, relogio); // cria o desenho do relogio lcd.createChar(1, setaC); // cria o desenho do relogio lcd.begin(16, 2);
// Relogio setTime(12, 00, 0, 1, 1, 2017); // Define hora/min/segundo - dia/mes/ano digitalWrite(A0, INPUT_PULLUP); // Seta o PULLUP no A0 pinMode(buz, OUTPUT);
Serial.begin(9600); }
void loop() { Serial.println(analogRead(A0)); while (telap) { // Tela principal lcd.setCursor(0, 0); // Escreve as opçoes do menu lcd.print(menu[selec]); lcd.setCursor(0, 1); if (selec < 2) lcd.print(menu[selec + 1]); if (!espera && ativado) { // Simbolo do relogio caso o despertador esteja ativo lcd.setCursor(15, 0); lcd.write(2); } //--------------------------------------------Testa os botoes if (analogRead(A0) < 995 && analogRead(A0) > 985 && selec > 0) { selec--; // Cima lcd.clear(); }//lcd.setCursor(3,0); lcd.print(" "); lcd.setCursor(0,1); lcd.print(" "); lcd.setCursor(9,1); lcd.print(" ");} if (analogRead(A0) < 980 && analogRead(A0) > 970 && selec < 2) { selec++; // Baixo lcd.clear(); } if (analogRead(A0) < 850 && analogRead(A0) > 835) { //Select telap = false; if (selec == 0) telah = true; // Tela de horas if (selec == 1) telaa = true; // Tela do alarme if (selec == 2) telac = true; // Tela de configuracao lcd.clear(); } Analise(); // Analisa se esta na hora de despertar delay(200); }
//-----------------------------------------------------------------Tela Configuração do Relógio int d1 = hour(), d2 = minute(), pos = 0; // Variaveis para a tela de configuração while (telac) { lcd.setCursor(5, 0); if (d1 < 10) lcd.print("0"); lcd.print(d1); lcd.print(":"); if (d2 < 10) lcd.print("0"); lcd.print(d2); if (pos == 0) { lcd.setCursor(6, 1); //Indica a posiçao da setinha lcd.write(1); } if (pos == 1) { lcd.setCursor(8, 1); lcd.write(1); } //--------------------------------------------------------Testa os botoes if (analogRead(A0) < 995 && analogRead(A0) > 985) { //Cima if (pos == 0) if (d1 < 23) d1 ++; if (pos == 1) if (d2 < 60) d2 ++; } if (analogRead(A0) < 980 && analogRead(A0) > 970) { //Baixo if (pos == 0) if (d1 > 0) d1 --; if (pos == 1) if (d2 > 0) d2 --; } if (analogRead(A0) < 935 && analogRead(A0) > 925) if (pos < 1) { pos++; //Direita lcd.setCursor(6, 1); lcd.print(" "); } if (analogRead(A0) < 920 && analogRead(A0) > 910) if (pos > 0) { pos--; //Esquerda lcd.setCursor(6, 1); lcd.print(" "); } if (analogRead(A0) < 850 && analogRead(A0) > 835) { //Select setTime(d1, d2, 0, 11, 11, 2017); telac = false; telap = true; lcd.clear(); } Analise(); //Analisa se esta na hora de despertar delay(100); }
//-----------------------------------------------------------------Tela de Alarme d1 = alarme[0], d2 = alarme[1], pos = 0; //Variaveis para a tela de configuração int d3 = ativado; while (telaa) { lcd.setCursor(0, 0); if (d1 < 10) lcd.print("0"); lcd.print(d1); lcd.print(":"); if (d2 < 10) lcd.print("0"); lcd.print(d2); lcd.setCursor(7, 0); if (d3) lcd.print("Ativado"); if (!d3) { lcd.setCursor(6, 0); lcd.print("Desativado"); } if (pos == 0) { lcd.setCursor(1, 1); // Indica a posiçao da setinha lcd.write(1); } if (pos == 1) { lcd.setCursor(3, 1); lcd.write(1); } if (pos == 2) { lcd.setCursor(10, 1); lcd.write(1); } //--------------------------------------------------------Testa os botoes if (analogRead(A0) < 995 && analogRead(A0) > 985) { //Cima if (pos == 0) if (d1 < 23) d1 ++; if (pos == 1) if (d2 < 60) d2 ++; if (pos == 2) if (d3 < 1) { d3 ++; lcd.setCursor(6, 0); lcd.print(" "); } } if (analogRead(A0) < 980 && analogRead(A0) > 970) { //Baixo if (pos == 0) if (d1 > 0) d1 --; if (pos == 1) if (d2 > 0) d2 --; if (pos == 2) if (d3 > 0) d3 --; } if (analogRead(A0) < 935 && analogRead(A0) > 925) if (pos < 2) { pos++; //Direita lcd.setCursor(0, 1); lcd.print(" "); } if (analogRead(A0) < 920 && analogRead(A0) > 910) if (pos > 0) { pos--; //Esquerda lcd.setCursor(0, 1); lcd.print(" "); } if (analogRead(A0) < 850 && analogRead(A0) > 835) { //Select alarme[0] = d1; alarme[1] = d2; ativado = d3; telaa = false; telap = true; lcd.clear(); } Analise(); // Analisa se esta na hora de despertar delay(100); } while (telah) { //-----------------------------------------------------------------Tela de horas lcd.setCursor(3, 0); lcd.print(getHour()); if (!espera && ativado) { // Simbolo do relogio caso o despertador esteja ativo lcd.setCursor(15, 0); lcd.write(2); } if (analogRead(A0) < 850 && analogRead(A0) > 835) { //Select telah = false; telap = true; lcd.clear(); } Analise(); delay(500); } delay(300); }
void Analise() { // Analisa se deu hora de despertar if (hour() == alarme[0] && minute() == alarme[1] && !espera && ativado) { lcd.clear(); lcd.setCursor(1, 0); lcd.print("Segure select"); lcd.setCursor(3, 1); lcd.print("para parar"); while (!espera) { tocar(musica, duracao); if (analogRead(A0) < 790 && analogRead(A0) > 555) espera = true; delay(200); } lcd.clear(); } if (espera && second() == 0 && ativado) { espera = false; } }
String getHour() { // Retorna uma string com a hora h:m:s String saida = ""; if (hour() < 10) saida += "0"; saida += hour(); saida += ":"; if (minute() < 10) saida += "0"; saida += minute(); saida += ":"; if (second() < 10) saida += "0"; saida += second(); return saida; }
<p>void tocar(char* mus[], int tempo[]) { int tom = 0; for (int i = 0; mus[i] != "Fim"; i++) { if (mus[i] == "Do") tom = 262; if (mus[i] == "Re") tom = 294; if (mus[i] == "Mi") tom = 330; if (mus[i] == "Fa") tom = 349; if (mus[i] == "Sol") tom = 392; if (mus[i] == "La") tom = 440; if (mus[i] == "Si") tom = 494; if (mus[i] == "Do#") tom = 528; if (mus[i] == "Re#") tom = 622; if (mus[i] == "Fa#") tom = 370; if (mus[i] == "Sol#") tom = 415; if (mus[i] == "La#") tom = 466; if (mus[i] == "Pausa") tom = 0; tone(buz, tom, tempo[i]); delay(tempo[i]); if (analogRead(A0) < 995 && analogRead(A0) > 835) { espera = true; // CONDIÇAO DO DESPERTADOR - Não tem relação com essa função break; } } }</p>
How to Use the Alarm Clock
![IMG_8952.JPG](/proxy/?url=https://content.instructables.com/FKX/EWL9/JO2S8ELM/FKXEWL9JO2S8ELM.jpg&filename=IMG_8952.JPG)
![Screen Shot 2018-11-05 at 14.56.54.png](/proxy/?url=https://content.instructables.com/FM6/GHS0/JO2S8NUU/FM6GHS0JO2S8NUU.png&filename=Screen Shot 2018-11-05 at 14.56.54.png)
Before you start actually using the alarm clock, there are a few things you should know:
- The potentiometer is used to regulate the luminosity of the screen. Rotate it to see what's best for you;
- To see the function of each button, check the second image above.
With that in mind, let's change the clock and set the alarm.
There are three options in the main menu: "Mostrar horas", "Definir alarme" and "Mudar as horas". To choose one, use the UP, DOWN and SELECT buttons. Firstly, you should go to "Mudar as horas" and change the time according to another clock or your cell phone, using the UP, DOWN, RIGHT, LEFT and SELECT buttons. Then, press SELECT to go back to the main menu. Now, go to "Definir alarme" to set the alarm. Using the LEFT, RIGHT and SELECT buttons, choose when you want the alarm to ring. When it does, the buzzer will ring until you press SELECT to stop it.
Go to https://drive.google.com/a/escolaeleva.com.br/fil.. to check out the alarm clock working!
My Experience
Although we faced some challenges along the way, me and my group managed to overcome them all with the help of our teachers (and Google, of course :)
I think this was a very challenging project, but it was really fun to see it work!
I hope you have a great experience as well!
If you have any questions, suggestions of improvements, or anything you'd like to talk about, please leave a comment bellow!