Use this guide to configure your **Marty V2's infrared (IR) foot sensor** and use its ground and obstacle readings in Blocks. ===== What is the IR sensor? ===== The IR foot sensor detects nearby objects in front of the foot and a surface underneath it. You can use these readings to make your program react to Marty's surroundings. {{ :martyv2:userguides:sensorsandaddons:img_1924.jpg?400 |The infrared sensor mounted on Marty's foot}} ===== How do IR Sensors Work? ===== - An infrared LED emits light towards the surface or object. - Some of that light reflects back towards a detector. - The sensor uses the reflected light to decide whether an object or the ground is detected. This is reflected-light sensing, not a physical contact switch or a precise distance measurement. The surface and lighting can affect the result, so check the readings on the surface where you will use Marty. ===== IR Sensor Set Up ===== Use the current [[martyv2:userguides:app|Robotical app]] to check the sensor's name and connection: - Turn on Marty and connect it to the app. If several devices are connected, select the Marty you want to configure. - Open **Robot settings**, then choose **Add-ons** to open **Manage Add-ons**. - Find the connected sensor with type **IRFoot**. Select its row or gear icon to expand its details. - Check **Add-on Type** is **IRFoot**. A colour sensor may also appear in this list; it is a different sensor. - If a name needs changing, edit **Name this add-on** and choose **Update Name**. Use **RightIRFoot** for an IR sensor on the right foot or **LeftIRFoot** for one on the left. If it is already named correctly, leave the name as it is. {{ :martyv2:userguides:sensorsandaddons:ir-addons-settings-2026-10.png?900 |The current Manage Add-ons screen with the connected RightIRFoot sensor expanded}} The screenshot shows **RightIRFoot** expanded. The grey **LeftColorSensor (Not Connected)** row is a saved configuration for a sensor that is not currently detected; it does not mean that RightIRFoot is disconnected. **Restore Add-on Names** is optional. It restores the standard names **RightIRFoot** and **LeftColorSensor**, and removes disconnected saved entries. If you use custom names or multiple sensors of the same type, name them individually with **Update Name** instead. If the sensor is missing or marked **Not Connected**, check its cable and reconnect Marty before continuing. If you have removed the sensor, follow this video to fit it again. Turn Marty off before changing sensor wiring. {{ youtube>ldpIoseIfVI?medium }} ===== Using IR Sensing in Blocks ===== - Return to **Home** and open **Blocks**, or open [[https://robotical.app/blocks|Blocks in the web app]]. Keep Marty connected. - Open your project and select the **Marty** sprite for the connected robot. If you have not added Marty to the project yet, follow the [[martyv2:userguides:martyblocks:start|Blocks guide]]. - In Marty's **Sensing** category, find **Foot sensor on the ground**. - Use the block's sensor dropdown to select your IR sensor by its configured name, such as **RightIRFoot**. With a connected sensor selected, **Foot sensor on the ground** reports **true** when a surface is detected beneath that sensor and **false** when it is not. **Foot Obstacle Sensed** is the separate block for detecting an object in front of the sensor. The sensor dropdown can include both IR foot sensors and colour sensors because both support these readings. Choose the sensor whose reading you intend to use. A missing sensor or unavailable reading can also produce false, so check the connection before treating false as an edge. ==== Example: react to the ground reading ==== Build this stack, then select your IR sensor in the dropdown: {{ :martyv2:userguides:sensorsandaddons:ir-ground-sensing-blocks-2026-10.png?900 |A Blocks program that repeats a ground-sensor check ten times and walks forwards or backwards}} **The screenshot uses `coloursensor_0F`. To try this example with the infrared sensor, change that dropdown to your IRFoot sensor's name, such as `RightIRFoot`.** The stack does the following: - **Get ready!** puts Marty into its ready pose. - **Repeat 10** runs the decision ten times. - If the chosen sensor detects the ground, Marty takes **one forward step** with a **5 mm** step length, **1 second** step time and **0°** turn. - Otherwise, Marty takes **two steps backwards**. Click the stack to run it. It checks the sensor at the start of each repetition; it does not continuously recheck the ground during a walking command. The stack shown has no green-flag start block, so clicking the green flag alone will not start it. Try the sensing block on a safe, flat surface before running the walking example. Test changes in the reading by supporting Marty and raising the sensor clear of the surface. Keep the walking example on the floor with room to move; it is not a guarantee that Marty will stop before a table edge.