Simon Says Game Using a Touchpad and Joystick
Project Description
This project makes an electronic version of the classic game, Simon Says. The user will use a combination of the capacitive touchpad and the five directional switch for input, and they will see their output on the uLCD and hear it on the speaker with sounds provided by the sd card and from analog output. The game starts with instructions on how to play on the uLCD screen. The rules are largely the same as any other variation of electronic Simon Says with the exception that inputs must be held at certain points due to the nature of input read functions. The game will end once the player has reached the programmed end goal of 3 successful rounds. This means the player has matched Simon’s output three times. From there the game will start over, and will continue as long as the board is powered on.
To start, one must set up their breadboard like so.
Pinouts
SD Card
Device Port | mBed pin |
---|---|
cs | p8 |
di | p5 |
vcc | vout |
sck | p7 |
gnd | gnd |
do | p6 |
cd | No connection |
Navigation switch (joystick)
Device port | Mbed pin | |
---|---|---|
+ | No connection | |
U | p17 | |
C | p16 | |
L | p15 | |
D | p14 | |
R | p13 | |
- | gnd |
uLCD
Device port | mBed |
---|---|
+5V | vu |
Rx | p27 |
Tx | p28 |
Gnd | gnd |
Res | p30 |
Touchpad
Device Port | mBed |
---|---|
GND | gnd |
SDA | P9 (+4.6k resistor to vcc) |
SCL | P10 (+4.6k resistor to vcc) |
IRQ | p26 |
VCC | vout |
Speaker
Device Port | mBed |
---|---|
+ | Vu |
Analog in (with resistor and transistor) | p18 |
Full diagram shown below (taken from this page)
Video Demo
Code
The code sets up the navigational switch class, and the touchpad interrupt. After those and the rest of the item initializations, the code lays out the drawing functions for the grid, as well as all the possible shapes. After that, the main game loop begins. The instructions are displayed, then the game begins. Inputs are read in, then the game proceeds. At the end of the game, affirmative or negative sound effects will play from the sd card.
Input Instructions
The player inputs are as follows :
-green squares match the corresponding spot on the touchpad (in the orientation depicted in the picture above!)
-green arrows match the navigational switch direection (in the orientation depicted in the picture above!)
-green circles match the navigational switch "fire"/center button
To have the game properly register your input, hold down the navigational switch input or touch the touchpad section when the blue circle with the sequence number in the middle comes up on screen. Otherwise, the game will not recognize your input, and you will lose.
Import programSimonSays
Simon Says game using joystick and touchpad
Please log in to post comments.