Skip to content

Anoushka-W/MastermindGame-RaspberryPi3

Repository files navigation

MastermindGame-RaspberryPi3

Project Overview

This project is a hardware implementation of the classic Mastermind game developed for the Raspberry Pi 3. It combines C programming and ARM Assembly to interface with external hardware including LEDs, buttons, and an LCD display through GPIO pins.

Features

  • Mastermind game logic implemented in C
  • ARM Assembly implementation of the matching algorithm
  • GPIO communication with LEDs and push button
  • LCD display integration
  • Unit testing support
  • Built using Makefiles

Demo

The project running on a Raspberry Pi 3 with the LCD display, LEDs, and push button connected.

Hardware Demo

Project Structure

  • master-mind.c - Main implementation of the Mastermind game in C.
  • mm-matches.s - ARM Assembly implementation of the sequence matching algorithm.
  • lcdBinary.c - Hardware interface for GPIO, LEDs, buttons, and the LCD display.
  • lcdBinary-assembly.c - Inline Assembly implementation for low-level hardware interaction.
  • Makefile - Build configuration for compiling and running the project.

Building and running the application

You can build the project by typing:

make all

and run the Master Mind program in debug mode by typing

make run

and do unit testing on the matching function

make unit

or alternatively check C vs Assembler version of the matching function

make test

The project uses an ARM Assembly implementation of the sequence matching algorithm (mm-matches.s) which is integrated with the main C application running on the Raspberry Pi.

The final application integrates the C implementation with the ARM Assembly matching algorithm while using inline Assembly for low-level hardware interaction with the LEDs, push button, and LCD display.

Unit testing

Example unit test:

> ./cw2 -u 121 313
0 exact matches
1 approximate matches

The application supports the following command-line format:

./cw2 [-v] [-d] [-s] <secret sequence> [-u <sequence1> <sequence2>]

Wiring

A green LED, as output device, should be connected to the Raspberry Pi 3 using GPIO pin 26.

A red LED, as output device, should be connected to the Raspberry Pi 3 using GPIO pin 5.

A Button, as input device, should be connected to the Raspberry Pi 3 using GPIO pin 19.

An LCD display, with a potentiometer to control contrast, should be wired to the Raspberry by as shown in the Fritzing diagram below.

You will need resistors to control the current to the LED and from the Button. You will also need a potentiometer to control the contrast of the LCD display.

The Fritzing diagram below visualises this wiring.

Fritzing Diagram

About

Raspberry Pi 3 implementation of the Mastermind game using C and ARM Assembly with GPIO-based LED, button and LCD interaction.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors