Tag Archives: relay timer


Programmable digital timer switch using a PIC Microcontroller

Digital timer switches are used to control the operation of electrical devices based on a programmed schedule. This project describes a programmable digital timer based on the PIC16F628A microcontroller that can be programmed to schedule the on and off operation of an electrical appliance. The appliance is controlled through a relay switch. This timer switch allows you to set both on and off time. That means, you can program when do you want to turn the device on and for how long you want it to be remained on. The maximum time interval that you can set for on and off operation is 99 hours and 59 minutes. The project provides an interactive user interface using a 16×2 character LCD along with 4 push buttons.

Programmable digital timer

Note: (June 30, 2016) A revised version of this project with added new features is posted here.

Circuit Design

The circuit diagram of this project is shown below. A 5V relay is driven by a PN2222 transistor that is controlled by RB3 pin of PIC16F628A. Digital inputs from the 4 push buttons are read through port pins RA2, RA3, RA4, and RB0. The functions of these push buttons are discussed in the operation section below. A standard 16×2 character LCD is used in the project to display the device status, program menu and time. The LCD is operated in 4-bit mode, therefore, only 6 I/O pins of PIC16F628A are required to drive it. A piezoelectric buzzer provides audible tone when the timer is started and stopped. It also beeps when the device is turned on or off. The + 5V power supply for the circuit is derived from a LM7805 regulator IC. The input to the regulator is given from a 9V DC wall adapter.

Read more