A line follower is a robot that can follow a track of black lines on a white background.

We will introduce an incredibly easy way to control this product using a GreenPAK configurable mixed-signal IC (CMIC) to implement the line follower control logic. A pre-made design file to program the GreenPAK chip with Line Follower logic will be provided making it easy to create the custom chip without much knowledge of how the line follower works. However, we will also explain the logic and inner circuitry of the GreenPAK in this instructable for those who are interested. The TCRT5000 reflective optical sensor will be used in this design that outputs a digital signal HIGH for white and LOW for black.

## Step 1: Create a Custom IC With Integrated Line Follower Logic

To implement the logic needed for the line follower, download the GreenPAK software and open this Line Follower design file. Hook the GreenPAK development board up to the computer, pop a SLG46537 chip into the socket and hit "Program". This pre-made design file in combination with the GreenPAK development platform will allow you to easily program the GreenPAK CMIC to become a custom IC with the appropriate line follower logic.

Once you have the chip, you can skip to step 3. However, if you would like to understand how the Line follower design file was created, see Step 2 for more details on the internal circuitry.

## Step 2: Logic for Line Follower

The logic we plan to use is shown in the Table above. Motor at 1 means that the motor is spinning and at 0 means that it is stopped in order to keep a simple design, we will only drive two motors. The motors are placed as shown in the red motor drawing. We could design the sensor array with any quantity of sensors we like, but it can be just three TCRT 5000 arranged as below. An ideal distance between the TCRT 5000s would be the width of the black line it is going to follow.

Following the normal process using the first table shown, we are to simply obtain the logical equations using Karnaugh ́s Maps for each motor.

The Karnaugh's map for the A motor is represented in the second table.

X state means that the combination is not expected to appear under normal circumstances, which means that it does not matter if the motor is either spinning or stopped

So the logic equation for the A motor is: AMotor = IN1

The B Motor map is described by the third table

X state means that the combination is not expected to appear under normal circumstances, which means that it does not matter if the motor is either spinning or stopped

So the logic equation for the A motor is: AMotor = IN1

The B Motor map is described by the third table

This gives us the logic equation for the B Motor:
BMotor=IN1 ́+IN2 ́IN3

Usually, in order to use only one or two types of logic gates, we do some Boolean algebra until we get the following equivalent equation.

BMotor=(IN1(IN2 ́IN3) ́) ́

This line follower is developed using simple logic, which means that going in reverse is not implemented.

In case the three sensors are outside the black line, IN 1, IN 2 and IN 3 will all be reading a HIGH, which for this configuration makes the car spin, until the black line can be found again.

On the other hand, when the three sensors are reading a LOW, the car stops moving altogether.

These equations are the logic for the basic line follower, and if we were to program it exactly in the same form, we obtain the configuration shown in the schematic above showing 3 logic gates in GreenPAK Design.

## Step 3: Line Follower Assembly

Connect the GreenPAK outputs to Motor A and B of your robot and the inputs to your TCRT5000 reflective optical sensor. To power up the GreenPAK, you can connect it to the 5V pin of the LN298N and power the same using a 12V battery as seen in the above figure.

Using this setup, we can also add more features to this basic design, implementing PWM to regulate the speed in which the line follower is moving, and enable us to implement a reverse condition if needed.

For more complete details on how to implement a line follower control circuit, download our full Line Follower application note.