Project tutorial
Line Follower Robot Using Arduino & 1Sheeld

Line Follower Robot Using Arduino & 1Sheeld © GPL3+

I worked on a line follower robot that track white line and follow it but not using LDRs or color sensor, but using my Smart Phone.

  • 3,128 views
  • 0 comments
  • 7 respects

Components and supplies

About this project

I tried to work on a very popular project but with a new tools and an easy way especially in coding. I worked on a line follower robot that track a white line and follow it but not using LDRs or commercial color sensor, I actually used my mobile phone as the color sensor and 1Sheeld that communicates between my mobile phone and Arduino to control the motion of the motors of the robot.

As well, I got some help from my friends in CAT Lab at Zewil city of Science and Technology who provide me with some tools and space to work in.

So let's begin illustrating the project.

Code

Arduino CodeArduino
This part is the best and describe the core part in the project. Basically, we will use the camera in the mobile phone to get the most dominant colors , function "setCalculationMode", in the view and by using "setPalette" function, it make the screen as a grid (for example 3 x 3) with a color in each cell corresponding to the most dominant color in that cell.

So we are concerned only with the first and third cells which are the left upper cell and right upper cell that indicates the boundaries of the camera view. So, if any of the third or first cells gets a color in stead of white so it means that the robot has to drift in that direction to maintain the robot to be in the center of the white color which is by the way has a hex value (0xFFFFFF
#define CUSTOM_SETTINGS
#define INCLUDE_TERMINAL_SHIELD
#define INCLUDE_COLOR_DETECTOR_SHIELD
#include <OneSheeld.h>

unsigned long white = 0xFFFFFF;
int motor1PWM = 3;
int motor1DIR = 4;
int motor2PWM = 6;
int motor2DIR = 7;

void setup() {
  OneSheeld.begin();
  ColorDetector.setOnSelected(&selected);
  pinMode(motor1PWM, OUTPUT);
  pinMode(motor1DIR, OUTPUT);
  pinMode(motor2PWM, OUTPUT);
  pinMode(motor2DIR, OUTPUT);
  
  digitalWrite(motor1DIR, LOW);
  digitalWrite(motor2DIR, HIGH);
}

void loop() {  
}

void selected()
{
  ColorDetector.setPalette(_3_BIT_RGB_PALETTE);
  ColorDetector.enableFullOperation();
  ColorDetector.setCalculationMode(MOST_DOMINANT_COLOR);
  ColorDetector.setOnNewColor(&newColor);
}

void newColor(Color one,Color two,Color three,Color four,Color five,Color six,Color seven,Color eight,Color nine)
{
  if (three == white && one == white)
  { moveForward(); }
  else if (three == white && one != white)
  { moveLeft(); }
  else if (one == white && three != white)
  { moveRight(); }
}

void moveForward()
{
  analogWrite(motor1PWM, 25);
  analogWrite(motor2PWM, 25);
  }

void moveRight()
{
  analogWrite(motor1PWM, 20);
  analogWrite(motor2PWM, 12);
  }

void moveLeft()
{
  analogWrite(motor1PWM, 12);
  analogWrite(motor2PWM, 20);
  }

Schematics

Dual_10A_driver.jpg
Dual 10a driver
IMG_20160511_171259.jpg
Img 20160511 171259
IMG_20160511_171228.jpg
Img 20160511 171228

Comments

Similar projects you might like

Super Easy to Build 1Sheeld 2 Wheel Drive Robot

Project tutorial by Garry Gerwer and Ahmed Hamdy

  • 16,684 views
  • 3 comments
  • 32 respects

Bluetooth Steering wheel for a robot using 1Sheeld

Project tutorial by Kristian Blåsol

  • 2,267 views
  • 1 comment
  • 13 respects

Line Follower Robot - PID Control - Android Setup

Project tutorial by MJRoBot

  • 28,042 views
  • 7 comments
  • 33 respects

Line Follower Robot

Project showcase by Lomas Subedi

  • 4,129 views
  • 2 comments
  • 9 respects

smart robot

Project in progress by Team Arduino Arab

  • 3,174 views
  • 1 comment
  • 9 respects

Voice Controlled Robot using your Smart Phone

Project tutorial by Ahmed Yassin

  • 3,059 views
  • 0 comments
  • 7 respects
Add projectSign up / Login