The block returns the state of the specified IR sensor. It returns True if the current IR sensor value is greater than the threshold value, else False.

The block returns the state of the specified IR sensor. It returns True if the current IR sensor value is greater than the threshold value, else False.

An IR sensor consists of 2 LEDs: one which transmits the IR light and one which receives the IR light. When the IR rays are transmitted, they bounce from the nearest surface and get back to the receiver LED. That’s how an IR sensor detects an object.
But to detect colors, we depend on the number of rays the surface reflects:


We can get the sensor values in PictoBlox and based on that value we can estimate whether the surface is black or white.
We will call the threshold value above which the sensor detects the black line. If the sensor value is less than the threshold, it means that the sensor hasn’t detected the line yet.


Now, run the script by clicking the green flag and bringing the black line of the track close to the IR sensor. One of the following three conditions will happen:



Now modify the script to add the detection value for the right IR sensor.









Copyright 2025 – Agilo Research Pvt. Ltd. All rights reserved – Terms & Condition | Privacy Policy