Open 7400 Logic Competition entry: Accelerometer Controlled Racing Game

My project is a simple video game in which you control a car and have to move it sideways in order to avoid obstacles.

The obstacles are represented by a 5×10 3mm red led matrix. The idea was to use a 10×10 matrix but I couldn’t get one of those where I live and I had to make one, I was running out of time (and red leds…) and I ended up with a smaller matrix. The rows are controlled with a CD4040 and the columns with a CD4017 through a pair of hex inverting buffers (CD4049).

This is simple diagram showing the main blocks;

And the schematic;

Car control

The first idea was to use digital CIs to do this. An up and down counter (CD4029) with a BCD to decimal decoder (CD4028) and a couple of buttons. Now, these kinds of games are included in nowadays smart phones and are controlled by the internal accelerometer. I thought it would be a nice idea to control this one in the same way.

I’m using a MMA7361 Freescale accelerometer. This tiny chip has an analog output and I was thinking about using an ADC with some sort of decoder logic circuitry to translate the analog voltage to a “digital position” to be used to activate one of square leds (those represent the car).  Then I remembered about the LM3914, a great simple chip that does exactly what I want. A great resource to know how to configure this device is this video by Dave Jones.

Obstacles’ speed

The obstacles’ approaching speed is controlled by changing the CD4017’s clock frequency. The clock source for that device is a 555 timer working as a VCO. Every time you successfully avoid the obstacles the speed increases making it a bit more difficult. Pin 9 of the 4017 (the pin controlling the column in front of the car) is the clock source for a CD4040. So, this counter will count up when the obstacles reach that last column. There is an R-2R ladder on the counter’s outputs and the whole thing is working as a DAC which output control the VCO frequency. The 555 timer will increase the frequency as you lower the voltage on pin 5, so I actually need to count down with the 4040. The chip only counts up so I had to add a CD4069 inverter between the counter and the resistor ladder.


The 4017’s output reaches the last position->the 4040 counts up->with the 4049 is counting down->the voltage generated by de resistor ladder decrease->the  555’s frequency goes up-> the obstacles approach faster.

There is 556 timer chip (dual 555 version) driving a small piezo speaker and every time you successfully avoid the obstacles you will hear a short “beep”.  One of the 555 timers inside that chip is configured as a monostable and is fired by the last output from the 4017. The short pulse generated by the monostable activates the other half of the 556 which is wired as a high frequency astable timer, and this last one drives the speaker.

Game over

There are five 3-inputs AND gates in charge of checking the car and the obstacles positions. In case of a crash (that is; the obstacle is in the last column and in the same row as the car) one of these AND gates will have a “high” output and fires another 555 timer with a monostable configuration. The pulse generated enables the astable oscillator inside the 556 timer. The difference is that it produces a much longer pulse and you’ll hear a longer “beep”.   The monostable’s long pulse will also reset some of the CIs in order to start a new game.

Generating new obstacles

The pulse train generated in the “win situation” by the astable oscillator is used as the clock of a second 4040 counter controlling the matrix’s rows. With the pulse train the chip will count up and generate a new obstacle configuration.


A pair of 7-segment display is driven by a couple of CD4026. The clock source for these chips is the last output of the 4017, so every time you avoid a crash the scoreboard increases by one.

When you reach level 32  the counter in the “DAC” section reset everything finishing the game. To change the number of levels you need to change the R-2R ladder and the number of outputs used from the 4040.

Here are some pictures of the setup,
CMOS driving game

CMOS driving game
You’ll find more here

And finally a short video,