0% found this document useful (0 votes)
3 views4 pages

Raspberry Pi Line Follower Setup Guide

This tutorial provides instructions for setting up and programming a Raspberry Pi to work with a 4-channel line follower. It includes wiring instructions, environment configuration, and program testing steps, detailing how to run the program and analyze its output. Key components include using the GPIO port for I2C communication and reading sensor data to achieve line following functionality.

Uploaded by

Ywhite Eric
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Raspberry Pi Line Follower Setup Guide

This tutorial provides instructions for setting up and programming a Raspberry Pi to work with a 4-channel line follower. It includes wiring instructions, environment configuration, and program testing steps, detailing how to run the program and analyze its output. Key components include using the GPIO port for I2C communication and reading sensor data to achieve line following functionality.

Uploaded by

Ywhite Eric
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Raspberry Pi Development Tutorial

V1.0

[Link] Ready

1.1 Wring Instruction


Connect the 5V, GND, SDA, and SCL pins on the 4-ch line follower to the
corresponding pins on the the Raspberry Pi.

Note:

1 If you are using the provided lithium battery, please connect the battery connector to

DC port on the Raspberry Pi, with red wire to the positive terminal (+) and black wire to the

1
negative terminal (-).

2 If the battery wires are not connected, do not directly connect them to other wires to

avoid a short circuit between the positive and negative poles, which may cause damage to

the device.

3 Please ensure that no metal comes into contact with the controller before powering on.

Otherwise, it may result in a short circuit and damage the controller.

1.2 Environment Configuration


Install NoMachine on your PC. The software package is located in “2. Software
Tools&Program Collections->01 Software Installation Packages-> Remote
Desktop Connection Tool”. For detailed instructions on how to use NoMachine,
please refer to the relevant tutorials.
Drag the program into the Raspberry Pi system image. Take placing them on
the remote desktop as an example. Please make sure to place the library file
and the program in the same directory.
Open the terminal. Input the command “sudo chomod a+x 4LineFollower” to
navigate to the directory where the program is located.

2. Program Test
This program uses the GPIO port to simulate the I2C communication, enabling
the communication of the 4-ch line follower.

2.1 Run Program


Open a new terminal. Input the command “python3 4LineFollower” to execute
the program.

2.2 Program Outcome


The 4-ch line follower detects the black line to achieve line following. When the
2
black line is detected, the terminal will print the obtained value of each serial
port.

2.3 Brief Program Analysis


 Import library

Parameter details:
smbus: the library used for communicating with the I2C device.
It is used to control the running time of program. For example, use
“[Link]()” in a loop to control the frequency of data update.
 Set I2C bus number and sensor address

I2C_BUS: sets I2C bus number to 1, indicating the usage of the first I2C bus in
the system.

IIC_ADDR:sets the I2C address of the 4-ch line follower to 0x78.

IIC_REAR_ADDR:sets the register address to 0x01.

 Read function value

read_word(): uses the “read_byte_data” of the [Link] object to read


specified address data, and returns the read value.
 Main function

3
Main(): main program entrance.
Use the try-except structure to capture the KeyboardInterrupt abnormity,
allowing to exit the program by pressing “Ctrl+C”.
while True loop: loops to read sensor data and print.
value = read_word(): calls “read_word()” function to read sensor data.
print(): prints the sensor status, extracting each sensor status with
displacement operation.
[Link](0.5): updates data every 0.5 seconds, controlling the loop execution
speed.

You might also like