Introduction: Line Follower Robot Using a Smart Phone
Traditional way of making a Line follower robot is by using IR array sensors, but in this project we want to make it in a smart way using evive, smart phone and 1sheeld. The camera of mobile phone captures and discretize the video using the 1sheeld app and send it to 1sheeld shield mounted on evive via Bluetooth communication. Since evive has inbuilt motor drivers, we just need to plug and play the motors. Lets make this.
Step 1: Components Required
We will be making an line follower robot using following:
- Any Android Smart phone (with camera and Bluetooth :) )
- 1Sheeld (http://1sheeld.com)
- evive (http://evive.cc)
- Two wheel Robot
- Masking tape (not necessary)
For making a two wheel robot (call it differential drive robot) with one castor, have a look at this Instructables : https://www.instructables.com/id/Making-a-Modular-D...
We need to install 1sheeld app in Android mobile phone, which can be found here: https://play.google.com/store/apps/details?id=com....
Step 2: Connect Phone to 1Sheeld
First install the app as mentioned in previous step.
- Start your phone's Bluetooth connection and try to connecting "1Sheeld" named Bluetooth. The password will be "1234".
- The open the 1Sheeld app and connect to the 1Sheeld shield. Then scroll down the menu and selecct the "Color Detector option".
- Now click on the shield icon near right top.
- Set the color detector settings as shown in image. Bits should be set to 3Bit. Full should be unchecked while Color and Common were selected.
- Also click on the Lock icon on bottom left side of app.
- You can now see the discritized image on screen.
You can use masking tape to stick the phone on your robot as masking tape will not leave any sticky glue on removing it form phone or robot.
Step 3: Program for Line Follower
1Sheeld gives output of color values. The video is divided in a matrix of 3X3 and total 9 numbers are returned to the function parameters. The numbering starts from left to right (row first) and then top to down (column second). We will only use the first row readings. The program is derived from 1Sheeld examples and it is modified for evive motor driver pinouts.
This code is made for black line in white background as you seen in the video. We have used following conditions:
- if (three == white && one == white) moveForward()
- else if (three == white && one != white) moveLeft()
- else if (one == white && three != white) moveRight()
All the codes can be found here: https://github.com/evivetoolkit/eviveProjects/tree...
Also we tried to improve the code little bit by adding history term, so that if robot losses line that it tries to come back.
Step 4: Tune the Parameter and Calibrate
We need to tune the parameters like the robot speed for left and right turn or the maximum speed.
Adjust the PWM values for both the motors in the functions: moveForward(), moveRight() and moveLeft().
Also we need to adjust the height of camera from ground so that the black line is captured in one "discritized" pixel (rememeber the 3X3 matrix) in 1sheeld app, ie. if we place the robot on the line at center, then the 1sheeld app should show black only in center pixel. You can select the pink icon on bottom of phone screen to see the real video for calibration.
Note that some smartphone may not have the camera on center, so fix the phone such that the camera is on centerline of robot. (In our case, the camera was not on center)
This steps will be our calibration steps.
Step 5: And the Robot Follows Line!
Test the robot and it should now follow the line.
You can improve the speed can calibrate to make it better.
Together with 1sheeld and evive, this would be very fun as both simplifies our life a lot.
Evive has tons of features for lots of varieties of projects. You can explore more about evive here:
Watch this video for more details:
We have a be nice policy.
Please be positive and constructive.