Skip to content

A number guess game using a PIC microcontroller, programmed in C (PIC C / CCS C compiler) for the CEN389 Embedded Systems course at Epoka University

Notifications You must be signed in to change notification settings

ktamburi/Guess-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Guess Game – PIC Microcontroller

Overview

This project implements a number guessing game using a PIC microcontroller, programmed in C (PIC C / CCS C compiler).
The assignment was to program the guess game application according to the provided keypad circuit and instructions.

The repository contains:

  • main.c β†’ Source code for the guess game (CCS PIC C).
  • main.hex β†’ Compiled hex file to load into the circuit.
  • Guess Game Circuit.simu β†’ Circuit simulation file for SimulIDE.

Features

The game behaves as follows:

  • First Player (secret number setup):

    • Enters a 4-digit number using the keypad (it is taken into account that the user will always insert 4 different digits).
    • Digits are shown on the first line of the LCD.
    • After the 4th digit, the number is saved and "SAVED" is displayed for 2 seconds, then the screen clears.
  • Second Player (guessing):

    • Has up to 10 guesses to find the number.
    • Each guess is displayed as "Guess#" followed by the entered digits.
    • After each guess, a hint is displayed in the format:
      • +n β†’ number of digits in the correct place
      • -m β†’ number of digits that exist but are in the wrong place
    • Example: if secret = 1357 and guess = 1325, hint shown is +2-1.
  • Winning condition:

    • If guessed correctly within 10 tries β†’ "YOU WIN" is shown for 5 seconds.
    • LED at PIN_B7 turns on for 5 seconds.
  • Losing condition:

    • If not guessed in 10 tries β†’ "YOU LOSE" is shown, and the secret number is displayed for 5 seconds.
  • After either outcome, the game resets and starts over.


Requirements

To run this project, you need:

  • SimulIDE β†’ for circuit simulation.

How to Run the Guess Game

  1. Open the circuit in SimulIDE:

    • Launch SimulIDE.
    • Open the file Guess Game Circuit.simu.
  2. Load the compiled code into the microcontroller:

    • In the circuit, click on the PIC microcontroller component.
    • Load the provided main.hex file.
  3. Run the simulation:

    • Press the Play button in SimulIDE.
    • First player enters a 4-digit number.
    • Second player makes guesses using the keypad.
    • Observe the results and hints on the LCD.

Assignment Reference

This project was created as part of Epoka University Course CEN389 – Embedded Systems homework.

About

A number guess game using a PIC microcontroller, programmed in C (PIC C / CCS C compiler) for the CEN389 Embedded Systems course at Epoka University

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages