Lab 3: Four bit binary counter using PIC16F688

Summary of Lab 3: Four bit binary counter using PIC16F688


This lab demonstrates a 4-bit binary counter using the PIC16F688 microcontroller. Four LEDs connected to RC0-RC3 represent binary values from 0 to 15, toggling on or off based on button presses at RC4. The system resets after reaching 15 and utilizes an internal 4.0 MHz clock with specific register configurations for digital I/O.

Parts used in the 4-Bit Binary Counter:

  • PIC16F688 microcontroller
  • Four LEDs
  • Current limiting resistors (470Ω)
  • Push button switch
  • Breadboard

Description

Today’s lab session is about binary counting LEDs. The binary 1 and 0 will be represented by turning LEDs on and off. You will make a 4-bit binary counter (using 4 LEDs) that counts from 0 to 15 (0000-1111 binary). The four LEDs are connected to RC0 through RC3 port pins of PIC16F688 with current limiting resistors (470Ω each) in series. A push button switch is connected to pin RC4 to provide input for the counter. The counter starts from 0, and increase by 1 every time the button is pressed. When the counter reaches 15 (all LEDs on), it will reset to 0 on the next press of the button.

binary counter

Required Theory

You should be familiar with the digital I/O ports of PIC16F688 and their direction settings. If you are not, read Digital I/O Ports in PIC16F688. Read previous lab session (Lab 2: Basic digital input and output) to learn about reading inputs from a push button.

Circuit Diagram

The circuit diagram and its construction on the breadboard are shown in figures below. The PIC16F688 microcontroller uses its internal clock at 4.0 MHz.

Software

Define PORTC pins RC0-RC3 as output, and the pin RC4 as an input. Disable comparators (CMCON0=7), and configure all I/O pins as digital (ANSEL=0). Use Button() function to read input from the push button switch.

 

For more detail: Lab 3: Four bit binary counter using PIC16F688

Quick Solutions to Questions related to 4-Bit Binary Counter:

  • How does the project represent binary 1 and 0?
    Binary 1 and 0 are represented by turning LEDs on and off.
  • What range does the 4-bit binary counter count through?
    The counter counts from 0 to 15, which corresponds to 0000-1111 in binary.
  • Which port pins connect the four LEDs?
    The LEDs are connected to RC0 through RC3 port pins of the PIC16F688.
  • What is the resistance value of the current limiting resistors?
    Each LED has a current limiting resistor of 470Ω in series.
  • Which pin receives input from the push button switch?
    A push button switch is connected to pin RC4 to provide input for the counter.
  • Does the counter reset automatically when it reaches 15?
    No, it resets to 0 only on the next press of the button after reaching 15.
  • What internal clock frequency does the PIC16F688 use in this circuit?
    The microcontroller uses its internal clock at 4.0 MHz.
  • How should PORTC pins be defined in the software?
    Pins RC0-RC3 must be defined as output and pin RC4 as an input.
  • What command disables comparators in the configuration?
    The command CMCON0=7 disables the comparators.

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