Laser assault course with PiFace Digital

Difficulty: medium

Fancy yourself as a secret agent? Ever wanted to navigate your way through a field of security laser beams like they do in the movies?

Setup laser tripwires with PiFace Digital

Pit yourself against a grid of laser beams with PiFace Digital. Now you can by following the simple steps in this guide.

As seen on: The Gadget Show

To make the laser assault course, we will point a laser beam from one end of the room to the other, to hit a sensor, that detects if the laser is hitting it. The type of sensor you will use in this project is called a phototransistor. If you fail on your mission and break a beam the RaspberryPi will let you know.

Warning: Never point a laser into your or anyone else's eyes!

What you will need

Connecting the sensor

Connect the longer leg of your phototransistor to ground on the PiFace Digital. Now connect the other leg of the phototransistor to the first input pin.

To protect your phototransistor, you may want to add a resistor into your circuit between the short leg of the phototransistor and the input pin.
A phototransistor circuit for the PiFace Digital
A phototransistor circuit for the PiFace Digital

Place your laser facing out into the room you want to make the assault course in. Position you mirrors to reflect the laser beam a number of times and end up hitting the phototransistor. You can increase the number of ‘tripwires’ by reflecting the beam back and forth with mirrors -- you just need to make sure the beam eventually hits the phototransistor.

Setting up the software and testing

Note: If you have not already, follow these instructions first, to install the PiFace Digital software.

To test your phototransitor circuit is working, start the PiFace Digital emulator by opening a Terminal window on your RaspberryPi and typing the command

Check that the emulator is talking to your PiFace board by pressing one of the on board buttons and watching the corresponding picture of the button in the emulator on screen change.

Now break the laser beam with your hand and check that this is registered to. You should see a similar effect to pressing the buttons.

You may find you need to reduce the amount of ambient light that is getting to the phototransistor, otherwise it may not detect that the laser beam has been broken. To do this, wrap your phototransistor in paper or coloured tape, with the top of the ‘bulb’ poking through. This will cut down the light that can get will only have one angle at which it can hit the sensor, which is the direction of the laser beam.

Download the software for the game from here.

Playing the game

Here’s an idea for an extension:

Want to know where a laser beam is being tripped? You can do this by using multiple lasers and Phototransistors instead of mirrors to reflect the beams. Wire and setup these in the same way you did for the first laser beam.

Two phototransistors connected to the PiFace Digital
Two phototransistors connected to the PiFace Digital

You could also write your own program for the game, such as putting a time limit in or creating your own sound effects.