Alarm Clock

Hey guys! :)

Today I'm here to show you how to do your own alarm clock! It's important to know that we were based in another website, called "Mundo Projetado" : http://mundoprojetado.com.br/despertador-usando-o-... . The code is from It is a simple project, but requires attention in some steps! The most disfficult steps are going to be in Caps Lock. So, if your project goes wrong, maybe you didn't do some steps.

The alarm clock works with a display, the buttons (that are going to command the display), a dimmer and a buzzer. It has the same functions as a regular allarm clock. However, look how awesome it is to create your own!

Some pictures are not original, and we will get them from "mundo projetado".

Step 1: Get Basic Materials

You will need:

- An arduino

- A bread board

- About 25 male-male jumper wires

The image of the bread board was gotten in this website:

https://www.elementzonline.com/bread-board-gl-12-8...

Step 2: Start Circuit 1

You will need:

- A buzzer

- two male-male jumper wires

Step 1: first, put the buzzer in the diviser part of the breadboard;

Step two: put two cables at the same vertical line of the diviser part of the breadbord at the two entrances of the buzzer;

Step three: get the other side of the cable that was on the POSITIVE entrance of the buzzer and put on the -10 pin in the arduino

Step four: get the other side of the cable that was on the NEGATIVE entrance of the button and put on the negative part of the arduino

Step 3: Start Circuit 2

You will need:

- A display

- A dimmer

- 15 male-male jumper wires

- A resistor with the exact same color (otherwise, you will need to change in the code)

Now, just follow the image.

OBS:

-The resister must have the same colors. Otherwise, you should change in the code.

-Be aware of the number of the pins in the display. It may change according to your display.

-You can put in the same breadboard of the previous step.

Step 4: Create Circuit 3

Buttons part!

You will need:

- 5 buttons;

- 5 male-mae jumper wires

- 6 resistor with the exact colors! (otherwise, you need to change in the code)

Now, just follow the image

OBS:

- YOU CAN PUT IN THE SAME BREADBOARD

- THE GREEN CABE (WITH THE ARROW IN THE PICTURE), IS CONNECTED TO THE A0 PIN IN THE ARDUINO!

Step 5: Final Touches on the Circuit...

- YOU MUST PUT 2 CABLES (INDICATED BY THE BLUE ARROWS) CONNECTING THE TWO PARTS OF THE BREADBOARD.

Step 6: THIS IS HOW THE CICUIT SHOULD LOOK LIKE

OBS:

- It's not going to appear anything in the display, you need to upload the code first, that we will see in the next step.

Step 7: Code Time...

Now is just install the arduino program and put in the code.

REMEMBER:

- iF YOU CHANGE THE LCD PINS IN THE ARDUINO, YOU MUST CHANGE IN THE CODE!!

- YOU MUST INSTAL TIME LIB HERE:

https://github.com/PaulStoffregen/Time

#include <TimeLib.h>
#include <LiquidCrystal.h>
 
 LiquidCrystal lcd(12,11, 5, 4, 3, 2); // inicializa a biblioteca do display com os pinos de interface
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; }
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;     }   } }

Step 8: Upload the Code to the Arduino

Now, is just plug the usb in the arduino and your computer, than upload the code! You should upload the code in the arduino program!

Step 9: How to Navigate in the Display...

To navigate in the display you will use the buttons: to go up, press the button up, to go left, press the button left, according the image.

The page:

  • Mostrar as horas: Shows the hour
  • Mudar horas: Change the hour
  • Definir alarme: You can set up the alarm

In the "definir alarme" and "mudar horas" you use the button up and down to put the number you want, left and write to change the position of what are you going to change, select to do changes.

In the "definir alarme" you can put the hour you want it to ring and to activate it or not.

In the screen "Mostrar horas", you press select to go back to the options.

When the alarm rings, you can press any button to turn it off. If you don't press anything, it will continue. Once you press, you need to turn it on in the "definir alarme" page again.

Step 10: THIS IS HOW IT SHOULD WORK!!!!!!!

Step 11: My Experience

I had never done anything like this before. I found this very hard at the beginning, but if you try to make every single step of this tutorial I'm sure you will succeed. I've tried to make the best I could for you to succeed, so leave a comment bellow if you need any help! I will be responding them :)

Thanks for the view and please leave a like bellow!

Share

    Recommendations

    • PCB Contest

      PCB Contest
    • Toys Contest

      Toys Contest
    • Make it Glow Contest 2018

      Make it Glow Contest 2018

    Discussions