Table of Contents

How to Build a Quarky 5-CH IR PID Line Follower in PictoBlox

Example Description
Learn how to build a smooth and accurate PID-based Line Follower robot using Quarky and the 5-CH IR Line Sensor Array in PictoBlox! In this project, Quarky reads real-time path data from five infrared sensors to make continuous steering corrections, detect track checkpoints, and execute precise turns at junctions.

Introduction

A 5-channel IR sensor array uses five horizontally arranged infrared sensors (IR-L, IR-SL, IR-C, IR-SR, and IR-R) to detect the exact position of a line beneath the robot. By analyzing these readings, Quarky knows whether it is moving straight, drifting to one side, approaching a junction, or reaching a checkpoint.

Unlike standard line following that makes abrupt left-and-right adjustments, PID (Proportional–Integral–Derivative) control calculates continuous steering corrections based on how far the robot drifts from the center of the line. In this project, we will configure the PID constants and speed parameters so Quarky smoothly follows a track, counts checkpoints, and makes a sharp turn at a junction.

Prerequisites

Step 1: Required Components

Before starting, make sure you have the following:

  • Quarky robot (charged and powered on)
  • 5-CH IR Line Sensor Array module

  • Compatible I2C connection cable.

  • A line-following track with checkpoints and junctions
  • Computer/Laptop with the latest version of PictoBlox installed

Step 2: Connect the 5-CH IR Sensor Array to Quarky

Mount the 5-CH IR Line Sensor Array onto the front of your Quarky robot, facing downward toward the track. Connect the sensor array directly to the Quarky board using the I2C pins as shown below:

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

(Ensure power and ground connections are properly aligned according to the board labels before powering on Quarky.)

Step 3: Select Quarky and Add the Extension in PictoBlox

  1. Open PictoBlox on your computer and log in to your account.
  2. Select the Block Coding environment.
    Select Block Coding in Pictoblox

  3. Click on the Board tab in the top menu bar and select Quarky.
    Select-Quarky-Board-PictoBlox

  4. Connect Quarky to your computer via USB cable or Bluetooth, and select Stage Mode (or Upload Mode if running standalone).
    change stage mode to upload mode in pictoblox

  5. Click the Add Extension button in the bottom-left corner of the Blocks Palette.
  6. Search for 5-CH IR Line Sensor Array and add it to your project.

Step-by-Step Block Coding Guide

Code 1: Initialize the Sensor Array and Configure PID Parameters

In this first part of the script, we initialize the 5-CH IR sensor array and set the turning speed, PID constants, and motor speed limits.

    1. Drag and drop the when green flag clicked block from the Events palette.
    2. Attach the initialize 5CH IR Line Follower block from the 5-CH IR Line Sensor Array extension to set up the I2C sensor communication.
    3. Add the set turning speed block and set its value to 45.
    4. Attach the set PID constants block and configure the tuning parameters:
  • Kp: 0.6
  • Ki: 0.0
  • Kd: 0.9
    1. Add the set PID speed parameter block and enter the speed limits:
  • base: 40
  • min: 0
  • max: 55

Code 2: Follow the Line Using PID, Turn at Junctions, and Detect Checkpoints

Next, attach the navigation blocks directly below the setup blocks to make Quarky follow the track, turn at the junction, and stop at the final checkpoint.

  1. Attach the do line following with PID until () checkpoint detected block and set the checkpoint count to 2. Quarky will smoothly follow the line using PID corrections until it crosses two checkpoints.
  2. Add the turn robot () to () line block below it, and select left and 2nd from the dropdown menus so Quarky turns left until its sensors align with the second intersecting line.
  3. Attach another do line following with PID until () checkpoint detected block and set the value to 2 so Quarky continues following the new path until it detects two more checkpoints.

Output

Place Quarky at the starting point of your track and click the green flag in PictoBlox to run the program. Quarky smoothly follows the black line with minimal wobbling, detects the first two checkpoints, executes a left turn onto the 2nd line, and continues PID line following until it reaches the next two checkpoints.

 

Conclusion

In this project, we built a 5-CH IR PID Line Follower robot using Quarky and PictoBlox. We configured PID constants (Kp, Ki, and Kd) along with base, minimum, and maximum motor speed parameters to achieve smooth, responsive steering. The project demonstrates how multi-channel infrared sensing, checkpoint counting, and junction turning work together for autonomous navigation. You can further customize this project by tuning the PID values for sharper curves or adding extra checkpoint actions along a more complex track.