Home / Projects / PIC Projects / Catch the Light PIC Game

Catch the Light PIC Game

This project is a simple PIC game where LEDs go on randomly one at a time. The objective is to “catch” the LED that’s on by pressing the corresponding button. For every catch, the score, displayed on a seven segment display, is incremented. The speed of the LEDs increase every time the score goes beyond multiples of 5 (10, 15, 20).

Introduction

This a good PIC project for beginners. All that is needed is four LEDs, four buttons and a dual 7 segment display. This project is coded using XC8. Here’s a video of the project simulated on Proteus ISIS:


Making the LEDs go random is done through the rand() command and using TMR1’s value as seed. Each LED has a corresponding button. If the user presses a button, the RB change interrupt is triggered and then the PORTB (buttons) value is compared to the PORTC (LEDs) values. If a match occurs, the score is incremented.

Materials Needed

  • PIC16F877A
  • Dual Seven-segment Display - Common Cathode
  • 74LS48
  • 5 x SPST Pushbuttons
  • 4 x LEDs
  • 5 x 10k ohm, 1/4 W Resistors
  • 5 x 200 ohm, 1/4 W Resistors
  • 4 MHz Crystal
  • 2 x 22pF Ceramic Capacitor

Schematic Diagram

Catch the Light! PIC Project Game

I wanted to use RB change interrupt for faster reaction time. And since this interrupt triggers via four pins (RB4 to RB7), this project is limited to four buttons and, consequently, four LEDs. More LEDs and more buttons is possible but you can’t use interrupts anymore.

Code

Project Files

The simulation files, XC8 code and schematic diagram is free to download:

Check Also

PIC16F877A Stepper Motor Controller

PIC16F877A Stepper Motor Controller

This project is a stepper motor controller featuring the PIC16F877A microcontroller and coded using XC8. …

Leave a Reply

Your email address will not be published. Required fields are marked *