Programmable digital timer switch using a PIC16F628A

Summary of Programmable digital timer switch using a PIC16F628A


This project builds a programmable digital timer switch using a PIC16F628A microcontroller to schedule on/off operation of an appliance via a relay. It supports on/off intervals up to 99 hours 59 minutes, uses a 16×2 LCD (4-bit mode) and four push buttons for user interaction, includes a PN2222-driven 5 V relay, a piezo buzzer for tones, and a 5 V supply from an LM7805 fed by a 9 V wall adapter.

Parts used in the Programmable digital timer switch:

  • PIC16F628A microcontroller
  • 16×2 character LCD (compatible with 4-bit mode)
  • PN2222 transistor
  • 5 V relay
  • Four push buttons
  • Piezoelectric buzzer
  • LM7805 voltage regulator
  • 9 V DC wall adapter (input supply)
  • 39 Ω resistor (for LCD backlight when present)
  • General purpose prototyping circuit board
  • Miscellaneous passive components and wiring (resistors, capacitors, connectors)

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 a 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 uses a 16×2 character LCD with 4 push buttons to interact with the user.

digital timer

Circuit Design

The circuit diagram of this project is shown below. A 5 V 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 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.

In the circuit diagram, the pins 15 and 16 of the LCD are shown open. These pins are available only in those LCDs that have a back light illumination LED. The pins 15 and 16 are the anode and the cathode of the LED. If your LCD has the back light LED, you can connect these pins to the power supply terminals with a 39 Ω resistor in series. The backlight LED enhances the readability of the LCD display in low illumination condition.

The complete circuit soldered on a general purpose prototyping circuit board is shown below.

 

For more detail: Programmable digital timer switch using a PIC16F628A

Quick Solutions to Questions related to the Programmable digital timer switch:

  • What microcontroller is used in the project?
    The project uses a PIC16F628A microcontroller.
  • How is the appliance switched on and off?
    The appliance is controlled through a 5 V relay driven by a PN2222 transistor controlled by PIC16F628A RB3 pin.
  • What is the maximum programmable on and off interval?
    The maximum time interval for on and off operation is 99 hours and 59 minutes.
  • How does the user interact with the timer?
    User interaction is provided via four push buttons read on RA2, RA3, RA4, and RB0 and information is shown on a 16×2 LCD.
  • How many PIC pins are used to drive the LCD?
    The LCD is operated in 4-bit mode and requires six I/O pins of PIC16F628A to drive it.
  • What powers the circuit?
    The circuit is powered by a +5 V supply from an LM7805 regulator whose input comes from a 9 V DC wall adapter.
  • Does the project include audio feedback?
    Yes, a piezoelectric buzzer provides audible tones when the timer is started, stopped, or when the device turns on or off.
  • Are LCD backlight pins used?
    Pins 15 and 16 (backlight anode and cathode) are shown open; if the LCD has a backlight LED you can connect them to supply through a 39 Ω resistor.
  • Where is the circuit assembled?
    The complete circuit is soldered on a general purpose prototyping circuit board.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter