5-CH IR Line Sensor Array

5-CH IR Line Sensor
Extension Description
Learn to use the 5CH IR Line Sensor Array with Quarky and Intellio in PictoBlox. Read sensors, follow lines, detect checkpoints, and apply PID control.

Introduction

The 5-CH IR Line Sensor Array Extension helps Quarky and Quarky Intellio robots follow predefined paths using five infrared sensors positioned across the front of the robot.

Each sensor detects whether a line is present beneath it. By analysing these readings, the robot can determine whether it is moving straight, drifting towards one side, approaching a junction, or losing the line.

The extension provides functions for:

  • Reading individual and combined IR sensor values.
  • Following lines automatically using predefined motor speeds.
  • Adjusting forward and turning speeds.
  • Detecting checkpoints along a track.
  • Turning left or right at junctions.
  • Performing PID-based line following for continuous steering corrections.

The same extension supports Quarky and Quarky Intellio, with the initialisation and hardware connection process adapted to the selected board.

Understanding the 5CH IR Sensor Array

A 5-channel IR sensor array consists of five infrared sensors arranged horizontally to detect the position of a line.

The sensors are named according to their physical positions, from left to right.

Sensor Position Function
IR-L Leftmost Detects a line towards the far left
IR-SL Slightly Left Detects a line slightly left of centre
IR-C Centre Detects a line directly beneath the centre
IR-SR Slightly Right Detects a line slightly right of centre
IR-R Rightmost Detects a line towards the far right

How Does the Sensor Array Work with Quarky Intellio?

When connected to Quarky Intellio, the sensor array communicates through a compatible Mini Expansion Board or Expansion Board.

The selected expansion board provides the I2C interface used to read sensor data and the motor-control interface used to move the robot.

The line-following program reuses the expansion board’s existing I2C object rather than creating a separate I2C bus.

This allows the sensor and motor-control functions to operate through the selected expansion board.

Connecting the 5CH IR Sensor Array with Quarky and Quarky Intellio

The connection process varies depending on whether you are using Quarky or Quarky Intellio.

Step 1: Connect the 5CH IR Sensor Array

For Quarky

Connect the sensor array directly to the Quarky board using the I2C connections.

5CH IR Sensor Array Quarky
D1 D1 (SDA)
D2 D2 (SCL)

The sensor communicates through Quarky’s configured I2C pins.

For Quarky Intellio

Connect the sensor array to the selected Mini Expansion Board or Expansion Board.

5CH IR Sensor Array Mini Expansion / Expansion Board
D1 SCL
D2 SDA

Next, connect the Intellio main board to the expansion board.

Quarky Intellio Pin Expansion Board Pin
A1 / D1 D1
A2 / D2 D2

This creates a communication path between Intellio, the expansion board, and the sensor array.

Important: The supplied wiring references use different D1/D2 signal-label conventions for Quarky and the expansion-board arrangement. Verify the SDA/SCL labels on the actual hardware before making connections. The tables above preserve the board-specific mappings supplied for this extension.

Step 2: Connect the Motors and Power Supply

For Quarky

  1. Connect the left and right drive motors to Quarky’s built-in motor outputs.
  2. Use the supported Quarky power configuration for the robot.

For Quarky Intellio

  1. Connect the left and right motors to their corresponding motor outputs on the selected Mini Expansion Board or Expansion Board.
  2. Connect the required external motor power supply directly to the expansion board, following its supported voltage and power specifications.
  3. Do not connect motor power to the Intellio main board as a substitute for the expansion board’s required supply.

Step 3: Verify the Connections

Before switching on the robot:

  1. Ensure all signal connections are secure and correctly labelled.
  2. Confirm that the sensor array and control board have compatible logic levels.
  3. Ensure all connected devices share the required common ground.
  4. Check that the motors are connected to the correct outputs.
  5. Confirm the power supply meets the board’s requirements.
  6. For Intellio, make sure the selected expansion board matches the program configuration.

Important: Disconnect the power supply before modifying the wiring.

Accessing the 5CH IR Line Sensor Array Extension in PictoBlox

Step 1: Open PictoBlox and select the Block Coding environment.

Select the Block Coding environment

Step 2: Open the Board menu and select either Quarky or Quarky Intellio, depending on your hardware.

Select the Quarky Board

Go to the Board and select Quarky Intellio

Step 3: Click the Add Extension button at the bottom-left corner of the Blocks Palette.

Step 4: Search for and select 5-CH IR Line Sensor Array.

select 5-CH IR Line Sensor Array

Step 5: Open the 5-CH IR Line Sensor Array category from the Blocks Palette.

Open the 5-CH IR Line Sensor Array blocks of Quarky and intellio

The extension provides blocks for sensor readings, motor speed configuration, junction navigation, standard line following, and PID-based line following.

Note: The extension uses board-specific initialisation blocks. The remaining line-following blocks provide common functionality for Quarky and Quarky Intellio.

Python Function Reference – Quarky and Quarky Intellio

The following table summarises the Python functions associated with the extension blocks.

Block Quarky Python Quarky Intellio Python
Initialise Line Follower LineFollower5IR(scl_pin=19, sda_pin=18) LineFollower5IR(i2c=mini.i2c, motor_driver=mini) or Expansion equivalent
Get Sensor Readings getirstate() getirstate()
Read All Sensor Readings getallsensorreadings() getallsensorreadings()
Turn Robot turnrobot5ir() turnrobotusingir()
Set Turning Speed setturningspeed() setturningspeed()
Set Forward Coast Delay setturningforwarddelay() setturningforwarddelay()
Set Line Following Parameters setlinefollowerparameter5ir() setlinefollowerparameter5ir()
Set Sharp Turn Speed setSharpTurnParameter5IR() setSharpTurnParameter5IR()
Standard Line Following followlineuntilcheckpoint() followlineuntilcheckpoint()
Set PID Constants setpidconstants() setpidconstants()
Set PID Speed Parameters setpidspeedparameter5ir() setpidspeedparameter5ir()
PID Line Following followlinepiduntilcheckpoint() followlinepiduntilcheckpoint()
Read More

PictoBlox Blocks

The initialization block sets up the 5-channel IR sensor array and prepares the selected board for sensor readings and robot movement.
This block initialises the sensor array using the selected Mini Expansion Board or Expansion Board connected to Quarky Intellio.
This Boolean block checks whether the selected infrared sensor detects the line and returns True or False.
This reporter block reads the states of all five IR sensors simultaneously and returns them as a single text value.
This block turns the robot left or right at a junction and moves it towards the selected line.
This block sets the speed at which the robot rotates while performing a junction turn.
This block sets a short forward movement duration used by the line-following system.
This block configures the forward speed and correction speeds used during standard line following.
This block sets the motor speeds used when the robot needs to make a sharp directional correction.
This block starts automatic line following and continues until the robot detects the specified number of checkpoints.
This block configures the three constants used by the PID controller.
This block configures the motor speeds used during PID-based line following.
This block starts automatic PID-based line following and continues until the robot detects the specified number of checkpoints.
All articles loaded
No more articles to load
This function initialises the sensor array using Quarky’s I2C interface and built-in motor-control
Syntax: LineFollower5IR((scl_pin=19, sda_pin=18))
Uses the Mini Expansion Board’s I2C and motor-control interfaces.
Syntax: LineFollower5IR( i2c=mini.i2c, motor_driver=mini)
Uses the Expansion Board’s I2C and motor-control interfaces.
Syntax: LineFollower5IR(i2c=intellioexpansion.i2c, motor_driver=intellioexpansion)
The function reads the sensor states through the I2C interface and returns the state of the selected sensor.
Syntax: getirstate(“center”)
The function combines the sensor readings into a five-character string, with each character representing the state of a sensor.
Syntax: getallsensorreadings( )
This function turns the robot left or right at a junction and moves it towards the selected line.
Syntax: turnrobot5ir(“right”, 1)
This function turns the robot left or right at a junction and moves it towards the selected line.
Syntax: turnrobotusingir(“right”, 1)
This function sets the speed at which the robot rotates while performing a junction turn.
Syntax: setturningspeed(50)
This function sets a short forward movement duration used by the line-following system.
Syntax: setturningforwarddelay(150)
This function configures the forward speed and correction speeds used during standard line following.
Syntax: setlinefollowerparameter5ir(95, 55, 95)
This function sets the motor speeds used when the robot needs to make a sharp directional correction.
Syntax: setSharpTurnParameter5IR(75, 40)
This function starts automatic line following and continues until the robot detects the specified number of checkpoints.
Syntax: followlineuntilcheckpoint(1)
This function configures the three constants used by the PID controller.
Syntax: setpidconstants(0.6, 0.0, 0.9)
This function configures the motor speeds used during PID-based line following.
Syntax: setpidspeedparameter5ir(32, 0, 55)
This function starts automatic PID-based line following and continues until the robot detects the specified number of checkpoints.
Syntax: followlinepiduntilcheckpoint(1)
All articles loaded
No more articles to load
Table of Contents