Despertador digital com microcontrolador 8051(89c51)

Digital alarm clock with microcontroller 8051(89c51)

Digital alarm with 8051 microcontroller(89c51,89c52) is a comprehensive project. Comprehensive in the way that its code is very extensive. Programming is not easy for everyone, and when it comes to programming a microcontroller, it becomes more complex to write code for the desired output if you are not familiar with the basics of programming. Digital alarm with 8051(89c51,89c52) microcontroller is an extension of digital clock with 8051(89c51,89c52) microcontroller design. The alarm works in the same way as digital clocks and cell phone alarms. Well, all alarms work the same 😀

8051 Microcontroller Digital Alarm – Project Requirements

  • 8051 Microcontroller (89c51 or 89c52)
  • alarm (I used a bell)
  • LCD 16×2
  • Variable potentiometer/resistor (to set LCD contrast)
  • 4×3 Keyboard (You can also use 4×4. 4×4 contains 4×3:D)
  • Crystal (11.0592 MHz)
  • Breadboard (Designing circuit. You can also design circuit on PCB (Printed Circuit Board))

Tutorials on the 8051 Digital Alarm Clock Project

It is not possible to explain every instruction in the code. For example, 16×2 LCD interface with 8051 microcontroller or 4×4 numeric keypad interface with 8051 microcontroller or how to generate suitable time delay using internal timers of 89c51 microcontroller cannot be explained in a single tutorial. So I made several tutorials about each component that is part of this project.

  • How to generate a one second delay with the 8051 microcontroller.
  • How to generate a one minute delay with the 8051 microcontroller.
  • How the 16×2 LCD works.
  • Digital clock with 8051 microcontroller.


All the above tutorials play a vital role in the 8051 digital alarm clock project. I will say that the code of all the above tutorials is part of this project. I just arranged the code in sequence with some minor modifications and made a one-line code flow to achieve the digital alarm clock functionality.

Digital Alarm Clock – Code Flow

When you run the program for the first time, you must set the clock time the same as the digital clock design (link provided above). Once you set the clock time, it will start running indefinitely unless you reset the microcontroller. Now, whenever you want to set an alarm, press the button located on the first coulomb and fourth line of the 4×3 keyboard. Pressing the button will lead to an event that displays messages on 16×2 LCD to set hours and minutes. Now set the alarm time.

Note: No external RTC (real time clock) interfaces with the 8051 microcontroller for time calculation. Instead, the 89c51 myrocontroller's internal timers are used to produce the clock time (see above digital clock with 89c51 tutorial).

89c51 Microcontroller Digital Alarm – Circuit Diagram

The project circuit is very simple. Connect the 16×2 LCD with port 1 of the 8051 microcontroller (89c51 or 89c52). Rd (read) Wr (write) and En (activate) signals are supplied to 16 × 2 LCD using 3-pin port 5, 6 and 7 of 8051 microcontroller (89c51 or 89c52). Port 0, pin 0, is used to operate the buzzer whenever the alarm time reaches the corresponding clock time. Port 2 is dedicated to our 4x3 keyboard. Lines are connected to pins 0, 1, 2 and 3 of port 2. Coulombs are connected to pins 5, 6 and 7 of port 2. The rest of the connections are simple, apply 5 V to pin 40 and pin 31. Connect the 11.0592 MHz crystal to pins 18 and 19. Ground pin 20. Connect the reset button to pin 9.
Digital alarm clock with 8051 microcontroller

Digital alarm clock with 8051 microcontroller
Photograph

Microcontroller digital alarm clock 89c51 – Project code

Coming to the code. First I included the necessary header file reg52.h . This header file must be included whenever you are writing and compiling your 8051 microcontroller program in keil ide. Includes all linkers and debuggers required for 8051 microcontroller configuration.

Then keyboard function is declared. This function checks the keys pressed on the 4×3 keyboard. Next comes the torch function. It is used to handle integer type numbers to be displayed on 16×2 LCD. Integers must be converted to 8-bit character format for display on 16×2 LCD.

Then single bits of ports are declared to connect our 4x3 doorbell and keypad. The next character matrices are declared and are used as messages to be displayed on 16×2 LCD under suitable conditions. delay function is used to generate some delay for suitable purposes. lcdcmd function is sending commands to lcd. LCD data function is sending and printing data on the LCD screen. checking conditions The function is checking conditions such as whether the seconds have reached 60 minute increments, whether the minutes have reached 60 hour increments, check whether the clock has reached the alarm time ring the bell.

Clock delay function is producing seconds, minutes and hours for us. lcdinit initializing the lcd. set time The function is to set the clock time each time the program is restarted. The user must enter the time using the 4×3 keyboard. start The function is printing the time on 16×2 LCD at the beginning of the program execution.


The above tutorials are very important if you want to understand the functions used in the code. If you don't care about code, just record the hex code, make the circuit and enjoy your creation 😀

The alarm is 12 hours, which means you can activate the alarm for the maximum period of 12 hours. Do not enter hours greater than 12 and do not enter minutes greater than 60. If you want to make the alarm more intelligent, simply insert more functions into it, such as setting the alarm for morning or afternoon time. Do some other work whenever the clock reaches the alarm time, such as turning on a lamp, turning on the hydraulic motor to fill the tank, or turning off the furnace. If you're really willing to do something extra, go ahead and give me your feedback.
Download the project code and hex file compiled in keil Uvision-2. If you have any questions about code or anything just leave a comment below. Your comments are greatly appreciated.
Digital Alarm Code

Conteúdo Relacionado

A network of sensors is embedded in every vehicle,...
The motor controller is one of the most important...
ESP32-CAM is a compact camera module that combines the...
A evolução dos padrões USB foi fundamental para moldar...
A SCHURTER anuncia um aprimoramento para sua conhecida série...
A Sealevel Systems anuncia o lançamento da Interface Serial...
A STMicroelectronics introduziu Diodos retificadores Schottky de trincheira de...
Determinar uma localização precisa é necessário em várias indústrias...
O novo VIPerGaN50 da STMicroelectronics simplifica a construção de...
A Samsung Electronics, fornecedora de tecnologia de memória avançada,...
O mercado embarcado tem uma necessidade de soluções de...
You have probably come across the term ' drag...
You probably have a support insulator if you've noticed...
You've probably seen stand an insulator sit on power...
You've probably seen shackle insulators enthroned on electricity poles,...
You have probably experienced situations where controlling a circuit...
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.