Real time clock with alarm and temperature monitor C code: In this project the PIC16F887 microcontroller runs with its internal oscillator 8 MHz, MCLR pin is configured as an input pin. A (anode) and K (cathode) are the back light LED pins.
![mplab xc8 update mplab xc8 update](https://i.ytimg.com/vi/E7dvo52MO6c/default.jpg)
VEE pin is used to control the contrast of the LCD.
![mplab xc8 update mplab xc8 update](https://microchipdeveloper.com/local--files/c:make-your-code-small-for-free/properties1.png)
VDD to +5V and A to +5V through 330 ohm resistor VEE to the variable resistor (or potentiometer) output pin VSS, RW, D0, D1, D2, D3 and K are connected to circuit GND (ground) The 20×4 LCD screen is connected to the PIC16F887 microcontroller as follows: Buttons B3 and B2 adjust alarm 1 and alarm 2 parameters (hours, minutes and ON/OFF), button B3 selects the parameter and B2 increments the selected parameter.Īlso, there is an LED connected to PIC16F887 pin RB4 (#37), this LED is used as an alarm indicator (alarm 1 and alarm 2), so if there is an alarm, the DS3231 pulls down the INT pin (RB0) which interrupts the microcontroller and the microcontroller turns the LED ON, here button B2 turns both the LED and the occurred alarm OFF. Time and date can be adjusted with B1 and B2, button B1 selects time or date parameter (time parameters: hours and minutes date parameters: day of the week, date, month and year) and B2 increments the selected parameter. These buttons are used to set time, date and alarms. In the circuit there are 3 push buttons: B1, B2 and B3. The DS3231 interrupts the microcontroller when there is an alarm (alarm 1 or alarm 2).
![mplab xc8 update mplab xc8 update](https://1.bp.blogspot.com/-oq-JwXsTu7E/VEVpqZRCNUI/AAAAAAAAtXQ/6V6kuTX5aPw/s1600/ccs6-ubuntu-energia.png)
The DS3231 board is supplied with 5V as the 2004 LCD and the PIC16F887 microcontroller, there are 3 data lines connected between this board and the microcontroller: SCL line is connected to pin RC3 (#18), SDA line is connected to pin RC4 (#23) and INT line is connected to external interrupt pin RB0 (#33). (All grounded terminals are connected together)