Introduction: Rootin', Tootin', Shootin' Game

About: Old dog still learning new tricks.

When I lived in Orange County, California two of the biggest employers of college kids were Disneyland and Knott’s Berry Farm. Because I had electronics training from the military I was able to get a job in the Knott’s shooting gallery instead of having to wear a funny costume. The rifles used high voltage flash tubes with focusing lenses and the targets used photo cells. The target counter circuits used germanium transistors set up as flip-flops. The transistors were becoming harder to find so someone had tried replacing them with silicon ones. Unfortunately, they found out that the fast switching times of the silicon transistors made them much more susceptible to noise. That meant that a single hit on the target would ripple through the counters and light all of the lamps at once. The lesson here is that sometimes slow is good.

Recently I was thinking about those days and decided to see if I could design a simple shooting game for my grandkids. The game detailed here pits two players against each other to see who can get to five hits first. I also decided to use a cheap red laser diode as the heart of the gun. You could use laser pointers if you want but the circuit I include for the gun ensures that you get a single shot instead of a steady on beam.

Step 1: Light Sensor Modules

At first I was going to just use photo transistors for the sensor circuits but then I discovered the light sensor modules shown above. I bought a pack of 10 for next to nothing from a China supplier. The modules do use a photo transistor but they run the sensor voltage into an LM393 comparator so it provides a digital output as well as an analog one. A potentiometer onboard can be adjusted to set the trip level of the comparator. It also includes a power on LED and an LED that lights when the comparator switches the digital output. That makes it easier to adjust the proper level.

Step 2: Target Hardware

The bulk of the hardware consists of 10 LEDs and 10 resistors. I used standard 5mm bright white LEDs for indicators 1-4 and a slow flashing LED for the 5th indicator. The switch is normally open momentary contact and is used to reset the game. The PIC microcontroller is a standard one that I’ve used in other projects. As you can see in the pictures, I built the LED modules separately in order to make it easier to locate them in a target.

Step 3: Gun Hardware

The basic hardware and schematic for the laser gun is shown above. I built mine into plastic toy airsoft guns. The barrel tube for the pellets is almost the perfect size for the laser diode modules and I was able to fit a battery holder for two AAA batteries in the opening for the magazine. There are plenty of cheap laser diode modules out there and basically they differ only in the value of the current limiting resistor mounted onboard. That resistor determines the voltage rating of the laser module. I use two AAA batteries so I picked 3 volt lasers. The switch is a single pole, double throw micro switch. The capacitor is used to force a single burst of light with every pull of the trigger. In one position of the switch the capacitor charges up and in the other position it discharges through the laser.

Step 4: Software

Like all of my PIC projects, the software is written in assembly language. What makes this project a bit unusual is that the Main routine does nothing because all of the action takes place in the interrupt handler. The PIC has a feature called interrupt-on-change which, in older PICs, generates interrupts on any positive to negative or negative to positive transition on an I/O pin. This particular PIC allows the software to set the interrupt source to be either the positive edge, negative edge, or both edges. The light sensor module will generate both edges on a transition so this feature is quite handy. In this case, the software waits until the sensor output switches back high (off) before the interrupt is generated.

When a sensor interrupt is received, the software temporarily disables that input and sets a timer. In effect, the timer acts like a debounce circuit for a switch. At the 8-MHz clock selected for the PIC and the setup for the timer, the total timeout is about 130ms. When the timer finishes, it also generates an interrupt. At that point, the sensor input is re-enabled. Each sensor input has its own dedicated timer so there is no conflict between players.

Each sensor interrupt will also light one of the LEDs for that player. Instead of a counter, the software uses a variable that has one bit set. That bit gets left shifted with each interrupt and is then OR’ed into the output port to light the next LED. When the last LED is lit, the interrupt handler disables further interrupts and that effectively locks out the other player. The reset switch is connected to the MCLR input of the PIC and the configuration bits are set to allow that function. When reset is pressed, the software will reinitialize and clear the LEDs.

That’s it for this post. Check out my other electronics projects at