Arduino UNO Alarm Clock and Calendar - The Firmware Source Code

Other projects from this group

Arduino UNO Alarm Clock and Calendar - The Firmware Source Code

This project is an alarm clock and Calendar firmware for Arduino UNO with LCD shield. It shows hour, minute, second, temperature, year, month, day...

Arduino UNO Alarm Clock and Calendar With Temperature Meter Source Code - Rev 1.2


Price:

 

Other projects from this group

 

This project is an “Alarm Clock and Calendar” firmware (.ino file) for Arduino UNO board with the character LCD shield.

The LCD shield has 5 on-chip buttons which send an analog value to the A0 pin and a reset button.

Also it has 5 ADC/IO pins header and 7 IO pins header (including UART Tx and Rx pins).

The “Alarm Clock and Calendar” project has two alarm programs and temperature sensor which shows in both of Celsius and Fahrenheit degrees, shows the time including seconds, shows the day of week and also the calendar can be selected/adjusted between Gregorian and the ancient Persian calendars.

In this project, A1 works as the temperature sensor input (ADC) and D12 works as the buzzer output for the alarm.

The source code contains the following files:

  1. ArduinoUNOClockCalendar.ino (Main handler file)
  2. functions.ino – Global functions file.
  3. settings.h – Configuration and settings header file.

Uploading the project

First open one of the files with Arduino program, then select “Arduino UNO” board in the tools menu.

Then plug your Arduino UNO board’s USB cable and select its “COM Port” and upload the program.


Clock and Calendar Project’s Schematic

Place the LCD shield on the UNO board and connect the buzzer and resistive temperature sensor (10K Ohm NTC) as the following schematic:

arduino uno clock calendar schematic

The schematic is so simple. The A0 pin works as the internal Keypad value ADC, A1 pin works as the temperature sensor ADC input and D12 works as the alarm output.

Also there is an optional battery power block as the alternative power source, when the main power cable is disconnected.

  • You can optionally add three 1.5V AA batteries (Battery Power Block) in case you want to save the time when the power cable is disconnected.
  • The power source (Vin) must be 5V when you are going to use the “Battery Power Block”.
  • The microcontroller doesn’t generate audio frequency, just it pulls up and down D12 and causes the Buzzer’s beep. So use a “5V Buzzer” not a speaker.

Clock and Calendar Settings

There are 5 adjustment buttons on the LCD shield: Select, Left, Up, Down and Right.

You can toggle the temperature value between Celsius and Fahrenheit degrees with pushing the “Left” button.

You can toggle the Calendar between the Gregorian and Persian date by pushing the “Down” button.

The LCD’s backlight can be turned on or off by pushing the “Right” button.

With pushing the select button, the minute will blink and you can adjust it by pressing the up and down buttons.

arduino uno clock calendar

By pressing the “SELECT” button again, the hour, year, month and day can be adjusted and finally the date will be saved in the eeprom memory.

  • It saves the date in eeprom memory every day at 00:00:00.

The “UP” button will lead you to the alarms setting menu.

alarm clock calendar arduino uno

With UP and DOWN buttons you can set the Alarm 1 on or off, then if you press SET again, the alarm’s hour and minute will blink and you can set with up and down buttons.

Then by pressing the Select button again, you can set the Alarm 2 and finally the settings will be saved in the eeprom memory.

  • The stars in the calendar show alarms are enabled.

Programming Manual

In the settings.h, you can define “TEMP_TEST_MODE” then the temperature will be shown in the ADC value.

So you can change the equation, in the “Temperature equation” section of the functions.ino file according to your sensor’s specification.

You can adjust the alarm playing time between 1 to 255 seconds with the following variable:

#define ALARM_TIME%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; 120 // 1-255 Seconds

The “unsigned const char ucAlarmBeep[32]” variable in settings.h file is the alarm rhythm.

There are 16 paired values in this variable. The first one is the pull-up time (in 16mS unit) and the second one is the pull down time.

With changing the following value, the eeprom data will be re-init:

#define EE_INIT%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; 0xAB

You can change the start date with the following values:

#define PERSIAN_YEAR_BASE%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; 2580 //2580/01/01 1400/01/01
#define GREGORIAN_YEAR_BASE%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; 2021 //2021/03/21

The total years is limited to 256, if you want more, you can change the following variable:

unsigned char ucCalendarYearsSpent;

to (65536 years):

unsigned short ucCalendarYearsSpent;

1.2
- Converted to Arduino UNO
- Bugs fixed
- Accurate timer
- Fahrenheit added
- Backlight toggle added

1.1
- Two alarm programs added
- Gregorian calendar added

1.0
- Clock
- Persian Calendar
- Day of week
- Temperature meter


Similar Projects: