text.skipToContent text.skipToNavigation

COVID-19 & Shipping Updates

In line with government guidelines, Jaycar Auckland stores Will be CLICK & COLLECT only. All other company-owned locations outside of Auckland will be Level 2. We encourage all customers to take advantage of free delivery for online orders over $99. We thank you for your support as we continue try to keep our community and stores safe. See here for the latest on delivery delays.

Memory Gesture Game

Download Project Resources View on Github

This project is all about creating a simple game to test your memory. hero image

Using the well-known gesture sensor module (XC3742) and OLED Screen (XC3728) it will show patterns on the screen comprising of left, up, right, down, circle, and wave; try to match the patterns with your own hand! First level is short and easy to follow but it will get progressively faster and more complicated as you advance through the levels.

animation

Play this game with your friends and see how far you can get.

Bill of Materials

Qty Code Description
1 XC4410 UNO Compatible Board
1 XC3728 OLED Display
1 XC3742 Gesture Sensor
1 WC6028 Plug Socket Jumper Leads

This is a relatively simple game to build, but if you wanted to make it more featureful:

Code Name Reasoning
XC4424 Buzzer Module Add some audio feedback in the game, to bzzt and zap when players get it wrong or not
XC4385 Circular LED Module A nice RGB circular display for effects and gestures
XC3714 7 Segment Display Module Show the current and high scores just like one of those retro arcade machines
XC3748 MP3 Module For the truely advanced, make your own mini version of DDR by adding this MP3 module

Although, if you're going to add some extra features, it might be best to use a bigger microcontroller, as the Atmel 328p is nearing it's size in this project.

How it works

Relatively simple game with a state machine; each of the pattern arrays are stored in flash memory so it leaves the working memory for the gesture sensor; We have also patched and improved the gesture sensor library, so be sure to use the very latest from github (https://github.com/Seeed-Studio/Gesture_PAJ7620). We have included the library in this folder which should work for you.

We had to work this code a little bit to make it fit on the UNO, if there's any glaring improvements you can see, feel free to submit a contribution to the code!

How to build

Circuit Diagram

circuit diagram

The circuit is simple, there's only two components to connect in and to make it simplier we're going to do a naughty and power the OLED via pins 6 and 7. While this is not ideal, the OLED module uses very little power so the atmega is able to supply enough power from this happily. If you know how to change it, feel free to; we just put it there to make the wiring and presentation a little simpler.

The gesture sensor connects to the I2C lines, which are SDA->A4 and SCL->A5; You can power the sensor off either 3v3 or 5v as it has a little regulator on there to drop it down to the 3v3 supply.

Programming

Once it's connected, power up the UNO and upload the code; remember to use our latest version of the paj7620 library, hopefully the Arduino IDE does this for you.

Adding new levels

Adding more levels is easy; it's all added into the levels.h file

1. Make new level array following the same pattern as the others:

// this must be const, this must have a unique name (such as "level3" )
// and it must have PROGMEM before the equal sign to store it in flash
const uint8_t level3[] PROGMEM = {
        GES_RIGHT_FLAG, //these are defined in  paj7620.h, link them
        GES_LEFT_FLAG,
        GES_UP_FLAG,
        GES_LEFT_FLAG,
        GES_UP_FLAG,
        GES_CLOCKWISE_FLAG,
        FINISHED}; //you must end it with FINISHED, or a null byte

2. Reference your level in the global level table:

The position of the level will indicate how fast it goes; further down the list will be faster.

const uint8_t *const levels[TOTAL_LEVELS] PROGMEM = {
        level1,
        level2,
        level3,
        /* TODO, your level here */
        level4,
        level5};

3. Increment the TOTAL_LEVELS counter at the top of the levels.h

This will allow all levels to be referenced

//at the top of the file
#include "paj7620.h"
#define FINISHED 0
#define TOTAL_LEVELS 5 //increase this to be the number of levels in the levels array

Changing the title screen

Use the instructions from our Shake the present project to generate a new title screen.

How to use

When you're on the title screen; wipe your hand over it to start the game.

title screen

It will then show you a pattern that you must memorise; after the pattern it will display "GO!" and you must replicate the pattern using the gesture sensor. You can make 5 mistakes for the entire length of the pattern, then it's game over; otherwise you move to the next level, which is a little faster, and longer, than the last.

To cheat and see the levels, check out levels.h file.