Alarm Clock

Your dream is to create your own alarm clock? If the answer is yes, you are in the right place, because here I will show you step by step the easiest way, so that you can do it.

Our project is based on the "Mundo Projetado" alarm clock. But my group and I made changes. If you want to take a look at the link I'll leave it here: http://mundoprojetado.com.br/despertador-usando-o-....

Step 1: Materials

To build the alarm clock, you'll need:

  • 1 computer;
  • 1 display;
  • 1 buzzer
  • 1 USB cable;
  • 1 arduino
  • 1 potentiometer
  • 5 buttons
  • 7 resistors - their values must be 100, 300, 500, 700, 900, 1.1 k, 1.3 k or very close.
  • 22 male-male jumper wires

Step 2: Build Circuit 1

To build the circuit 1, you'll will need the arduino, the potentiometer and the display. You also will need 15 jumper wires and one of the resistors.

Follow the images that you will succeed!

Step 3: Build Circuit 2

You have arrived at Circuit 2, where you'll need 5 buttons, 6 remaining resistors and 5 of the jumper wires.

Follow the images that you will succeed!

Step 4: Build Circuit 3

Now you have arrived at Circuit, ypu'll need the arduino, 2 remaining jumper wires and the buzzer.

Follow the images that you will succeed!

Step 5: The Code

If you do not already have the Arduino application and TimeLib do these downloads first. After you have done this, copy and paste the code below into a new Arduino document, DO NOT forget to upload the code!

I will give two important tips for you to do:

  1. Connect the arduino to yhe computer;
  2. Check if you put the jumper wires in the right places of the arduino

Code:

#include #include LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // inicializa a biblioteca do display com os pinos de interfacebyte 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 menuchar selec = 0; // Variavel do menu principalint alarme[2] = {06, 00}; // Variavel do alarmebool 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 Thronesint duracao[] = {500, 500, 500, 500, 500, 500, 500, 500};void tocar(char* mus[], int tempo[]);int buz = 13; // 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);}void loop() { 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) < 195 && analogRead(A0) > 50 && 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) < 380 && analogRead(A0) > 195 && selec < 2) { selec++; // Baixo lcd.clear(); } if (analogRead(A0) < 790 && analogRead(A0) > 555) { //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) < 195 && analogRead(A0) > 50) { //Cima if (pos == 0) if (d1 < 23) d1 ++; if (pos == 1) if (d2 < 60) d2 ++; } if (analogRead(A0) < 380 && analogRead(A0) > 195) { //Baixo if (pos == 0) if (d1 > 0) d1 --; if (pos == 1) if (d2 > 0) d2 --; } if (analogRead(A0) < 50) if (pos < 1) { pos++; //Direita lcd.setCursor(6, 1); lcd.print(" "); } if (analogRead(A0) < 555 && analogRead(A0) > 380) if (pos > 0) { pos--; //Esquerda lcd.setCursor(6, 1); lcd.print(" "); } if (analogRead(A0) < 790 && analogRead(A0) > 555) { //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) < 195 && analogRead(A0) > 50) { //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) < 380 && analogRead(A0) > 195) { //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) < 50) if (pos < 2) { pos++; //Direita lcd.setCursor(0, 1); lcd.print(" "); } if (analogRead(A0) < 555 && analogRead(A0) > 380) if (pos > 0) { pos--; //Esquerda lcd.setCursor(0, 1); lcd.print(" "); } if (analogRead(A0) < 790 && analogRead(A0) > 555) { //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) < 790 && analogRead(A0) > 555) { //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;}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) < 790 && analogRead(A0) > 555) { espera = true; // CONDIÇAO DO DESPERTADOR - Não tem relação com essa função break; } }}

Step 6: How to Use Alarm Clock

If you got here, congratulations! I'm happy to help you, but now let's go to the last step.

There are three options in the main menu:"Definir alarme", "Mostrar horas" and the last one is "Mudar horas". To choose one, use UP, DOWN and SELECT buttons. You should go to "Mudar as horas" and change the time according to another clock or you cell phone, using the UP, RIGHT, LEFT and SELECT buttons. Then, press SELECT to go back to 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 untill you press SELECT to stop it.

go to this link, it will show the alarm working: https://drive.google.com/drive/folders/0AD0v4j6UA0...

Share

Recommendations

  • First Time Author

    First Time Author
  • Big and Small Contest

    Big and Small Contest
  • PCB Contest

    PCB Contest

2 Discussions

0
None
Penolopy Bulnick

21 days ago

Very nice job with your first Instructable! Looks like a fun project :)