Obstacle Sensing

What is the Obstacle Sensor?

The Obstacle sensors in Marty use infrared (IR) light to detect whether there is an obstacle in-front of Marty. Just like the technology you'd find in some cars while reversing, that beeping as you reverse closer to an obstacle uses the same technology as Marty's sensors.

How do IR Sensors Work?

  1. Infrared light is emitted from the IR LED emitter
  2. The beam of light hits the object and gets reflected back in an angle
  3. The reflected light will reach the light detector
  4. The sensor in the light detector determines the position/distance of the object

Where are Marty's IR Sensors?

On the front of your Marty V2's feet you will either have:

  • 2 'Infrared Foot' sensors (1 sensor on each foot)


  • 1 'Infrared Foot sensor' on Marty's right foot and a 'Colour Sensor' on Marty's left foot (the colour sensor has an IR sensor built-in). The shield needs to be placed under the IR sensor in order to work as an obstacle detector.

This is what the IR sensor looks like:

What Does Obstacle Sensing Look Like In Scratch?

You can learn to use detect obstacles with Marty in our free online lesson, here!

You can use obstacle sensing in Scratch to code Marty to react when something blocks the sensor on the front of its foot. In the following example, Marty will continuously walk forwards 1 step until an obstacle is detected and then Marty's eyes will turn angry and it will stop walking: