Table of Contents

is () IR sensor active?

Description

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.

Example

The example demonstrates how to calibrate the IR sensors to detect black lines on the white surface.

Logic

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:

  1. The dark surface will absorb more IR rays and as a result, the receiver will get fewer IR rays.
  2. White or shiny objects will absorb fewer IR rays and as a result, the receiver will get more IR rays.

We can get the sensor values in PictoBlox and based on that value we can estimate whether the surface is black or white.

  1. If the sensor detects the black line, its output value is increased. This means that the sensor is active.
  2. If it detects the white area, its output value decreases. This means that the sensor is inactive.

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.

Alert: IR sensors DON’T work in sunlight. IR rays from the sun increase the overall threshold of the sensors therefore they stay active all time. A closed environment or nighttime is the place/time to work with your line following robot.

Script

Calibrating the IR Sensors

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:

  1. Your calibration value is HIGH: The black region will not be detected in this case. Reduce the calibration value.
  2. Your calibration value is LOW: The white region will not be detected in this case. Therefore, increase the calibration value.
  3. Your calibration value is OK. The white and black regions are detected accurately.

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

Output

Read More
The example demonstrates how to make a vertical robot pet that senses the hand on the IR sensor and acts accordingly.

Script

Alert: You need to calibrate the IR sensor values to make this program run perfectly.

Output

Read More
The example demonstrates how to make a line follower robot with Quarky.

Logic

Script

Alert: You need to calibrate the IR sensor to get the best line detection by the robot. Also, you need to calibrate the speeds to make the robot follow the line correctly.

Output

Read More
All articles loaded
No more articles to load