BBC micro:bit
IR Break Beam Sensor


This IR Break Beam sensor comes in two parts as you can see in the image. It is sold by the US electronics company Adafruit and can be picked up from online suppliers in the UK.

IR Break Beam

On the right, you have an emitter that sends out infrared light. On the left, you have a receiver. When these are lined up, the receiver senses the IR light which can be read on the yellow signal line. The beam can be up to 50cm if using 5 volts, a bit less using the onboard 3V3 supply.

The sensor isn't cheap but it gives a quick, accurate reading that makes it usable in some interesting projects.


Connect the ends as follows and line up the emitter and receiver to make your beam. Go for about 10cm for a test.

IR Break Beam Circuit


Here's a simple test program to see if the sensor works. There is some serial output to help you know what is going on. Open up the REPL window or use a terminal emulator to see the printed output.

from microbit import *

last_reading = 0
print("Beam Ready")

while True: 
    reading = pin0.read_digital()
    if reading==0 and last_reading==1:
        print("Broken at", running_time())
        print("Beam Ready")
    last_reading = reading


  1. Buzzers and more lights would make for a decent burglar alarm or a more advanced version of the Feline Detection System.
  2. The break beam makes an interesting switch. You can trigger it with hands or feet.
  3. If you have a table top football game of some variety, you could add your own goal line technology system.
  4. Any miniature, table top game that has some sort of aiming and hitting component, like tiddlywinks or basketball.
  5. Make a suitable target and aim ping pong balls at it to score points.
  6. Make a reaction game. Display an image after a random amount of time. Use the break beam to determine how long it took the person to react.
  7. Using two of these sensor kits, you can do reasonably accurate timing and speed calculations. Cut out any lines of code that you don't need and reduce the gap between readings. Measure the distance between the sensors. Write a program to calculate the time difference between each of the sensors firing. With the distance and time, it is possible for you to work out the speed of whatever object was breaking the two beams.