"Intelligence and capabilities are very subjective. Even the simplest action may become the best intelligent way of tackling an issue at a point in time."
– Dr. Prahlad Vadakkepat

ALARM CLOCK USING PIC 18F452


I programmed a PIC microcontroller to be employed as the heart of an Alarm Clock. I know, it is not a big thing, the thing is that I have not interfaced any Real Time Clock ICs or any devices that provides Real Time Values. When I thought of doing this project a couple of weeks before, I just googled thinking in my mind that I would get some help from some forums, but alas the result was negative. I dint stop , went ahead and now the breeze of relief is touching my mind. Yes the net product has some limitations, then too I have did it. I would like to share this with you people.

The PIC Microcontroller that I used was PIC 18F452, having 32K of flash memory, 1536 bytes of RAM and 256 bytes of EEPROM memory. It is a 40 pin IC having about half a dozen of inbuilt peripheral modules. I dint design a dedicated circuitry for the whole project, rather I used PIC development board and associated peripheral modules designed and supplied by our company, Blue Apple Technolabs Pvt Ltd.


Modules and Components Used:-

1.PIC 18F452

2.PIC development board

3.4x4 Keypad Module

4.2x16 LCD Module

5.Buzzer Alarm Module

6..FRC Cables for interconnections


Software tools:-

1. MPLAB IDE v8.10

2. HITECH PIC18C Compiler

3 PIC 18 Simulator IDE for software Simulation.


Basic Idea


Basic idea of the project is so simple.

. A stop watch which counts from 00:00:00 to 23:59:59 , which resets to 00:00:00 and again continues the count.

. While pressing a particular key, say a TIME EDIT KEY, first line of the LCD will display HH:MM:SS. Now values can be entered into the Hour , Minutes and Seconds location through Keypad.

. When an invalid value is added in Hour, Minutes and Seconds locations, say a value 75 in minutes location , an ‘X’ sign will be displayed in the same line and the display is reset to HH:MM:SS. User has to re-enter all the values.

. Upon pressing an ENTER key the counter should start counting from the entered value in seconds location . Upon reaching 59, a 1 should be added to the value entered in minutes location and upon reaching 59 in minutes location a 1 should be added to the value entered in hours location. And this process should go on.

. Alarm can be set and the alarm time is displayed in the Second line of the LCD.

. While pressing a ALARM EDIT KEY, values can be entered to HH:MM:SS location.

. Here too, an ‘X’ sign will be displayed in the second line upon entering an invalid value.

. When the clock value ( Displayed in the 1st line) and the Alarm value (Displayed in the 2nd line) becomes same, an alarm will be generated using a buzzer.

. Alarm is stopped by pressing Alarm Stop key


Interfacing


Interfacing an LCD was discussed earlier. Data lines of the LCD is connected to PORT D and Control lines to RA0,RA1 and RA2. Please go through my older posts. The next module that is to be discussed is the Key pad module. As told earlier a 4x4 keypad is used. The interfacing is done in the simplest way.

Steps

  • Connect the keypad to any of the ports of the PIC. Here PORT C
  • Output 0F through PORTC.
  • Read back PORTC and store the value in variable1. A value other than 0F will be available from PORTC, if a key press is detected
  • Output F0 through PORTC.
  • Read back PORTC and store the value in variable 2. A value other than F0 will be available from PORTC, if a key press is detected

  • Take variable 3 and save the logical ORed result of Variable 1 and variable 2 in it.
  • Particular value of the key pressed is assigned to the value in Variable 3 by using switch statement.


Values in variable 3 when each key is pressed.


Please Refer program for further clarifications.



Video Demo




Program
Tools Required- MPLAB V 8.10 and HITECH PIC18 C
To download the program click on the thumbnail below-

Alarm_clock
Alarm_clock.rar
Hosted by eSnips
Happy Learning :)