Fork me on GitHub

Project Notes

#043 HitTheLights

A simple LED game with LCD output.

Notes

This is a quick build in response to a question on EE.SE. It demonstrates there’s no issue driving a series of LEDs and a 16x2 LCD at the same time.

Game Mechanics

I’m not sure what the OP had in mind, but here’s my version of the game:

Objective

  • turn off all the LEDs as fast as possible

Rules

  • LED1 to 4 turn on for a brief period in sequence
  • pressing the button while the LED is on will disable it
  • LEDs need to be disabled in sequence, LED4 to LED1
  • game is over when all LEDs are off

The code keeps track of the current best score. It is not saved so will be lost over each reset of the Arduino.

The code is easily modified to do things like crank up the difficulty on each attempt. With the default settings, the game is stupidly easy to play i.e. the anti Flappy Bird of the Arduino world.

Handling the Button Press

Pushbutton is connected to pin 2, which is attached to hardware interrupt 0.

Normally the input is pulled low, but when the button is pressed, the pin is pulled high, triggering the RISING interrupt.

There is no debouncing implemented. Not that it matters much wiht this circuit, but I haven’t seen any bouncing quirks so far.

Construction

The Breadboard

The Schematic

The Build

Credits and References

About LEAP#43 LCDHuman InputArduino
Project Source on GitHub Return to the LEAP Catalog

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

LEAP is my personal collection of electronics projects, usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting (IMHO!).

The projects are usually inspired by things found wild on the net, or ideas from the sources such as:

Feel free to borrow liberally, and if you spot any issues do let me know. See the individual projects for credits where due. There are even now a few projects contributed by others - send your own over in a pull request if you would also like to add to this collection.