Controlling a low-cost robot with two potentiometers

Controlling a low-cost robot with two potentiometers © GPL3+

This tutorial will present a simple way to control directions of robot with two potentiometers and several wires.

  • 1,378 views
  • 0 comments
  • 1 respect

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

Introduction

Since we watched Star Wars and other sci-fi movies, we always see autonomous robots around us. The overall goal of our project was to make a simple line follower. As a preliminary step, this tutorial will present a simple way to control directions of robot with two potentiometers and several wires.

We are a group of 1st year students at CentraleSupélec Rennes. This work is part of a short-term project we must achieve using our knowledge in electronics, signal processing and so on.

The features

For this Hackster tutorial, we will make the robot move according to two potentiometers (one for each wheel):

  • Potentiometer value will “decide” of the wheel speed.
  • If both potentiometers have the same value, the robot will go straight forward.
  • If different values are observed, the robot will turn left/right.

One remark: we decided to use a motor shield as the basic Arduino Uno cannot deliver enough current to control motors. Without this shield, wheels didn’t behave correctly. For the following schematics, we will use the official Arduino motor shield.

Perspectives

For later applications, there are several perspectives:

  • Implementing a wireless connection between the potentiometers and the robot (using NRF24L01 chips).
  • Developing an Android app to communicate with our system (wheels parameters, battery level, etc).

Here is a video of the result:

Code

Two-potentiometer commandArduino
int roue_droite = 10;
int roue_gauche = 11;
int potentiometre_direction = 2;
int potentiometre_vitesse = 3;

void setup() {
  pinMode(roue_droite, OUTPUT);
  pinMode(roue_gauche, OUTPUT);
  pinMode(potentiometre_direction, INPUT);
  pinMode(potentiometre_vitesse, INPUT);
}

void loop() {
  if (analogRead(potentiometre_direction) <= 100)
    { analogWrite(roue_droite,255 );
    analogWrite(roue_gauche, 0);
    delay(10);
  }
  if (analogRead(potentiometre_direction) >100 && analogRead(potentiometre_direction) < 200)
    { analogWrite(roue_droite,230);
    analogWrite(roue_gauche,25 );
    delay(10);
    }
  if (analogRead(potentiometre_direction) >200 && analogRead(potentiometre_direction) < 300)
    { analogWrite(roue_droite,200 );
    analogWrite(roue_gauche,55 );
    delay(10);
    }
  if (analogRead(potentiometre_direction) >300 && analogRead(potentiometre_direction) < 400)
    { analogWrite(roue_droite,175 );
    analogWrite(roue_gauche,80 );
    delay(10);
    }
  if (analogRead(potentiometre_direction) >400 && analogRead(potentiometre_direction) < 500)
    { analogWrite(roue_droite,155 );
    analogWrite(roue_gauche, 100);
    delay(10);
    }
  if (analogRead(potentiometre_direction) >500 && analogRead(potentiometre_direction) < 600) 
    { analogWrite(roue_droite,0 );
    analogWrite(roue_gauche,0 );
    delay(10);
    }
    if (analogRead(potentiometre_direction) >600 && analogRead(potentiometre_direction) < 700) //aller  droite
    { analogWrite(roue_droite,100 );
    analogWrite(roue_gauche,155 );
    delay(10);
    }
    if (analogRead(potentiometre_direction) >700 && analogRead(potentiometre_direction) < 800)
    { analogWrite(roue_droite, 80);
    analogWrite(roue_gauche,175 );
    delay(10);
    }
  if (analogRead(potentiometre_direction) >800 && analogRead(potentiometre_direction) < 900)
    { analogWrite(roue_droite,55 );
    analogWrite(roue_gauche,200 );
    delay(10);
    }
  if (analogRead(potentiometre_direction) >900 && analogRead(potentiometre_direction) < 1000)
    { analogWrite(roue_droite,25);
    analogWrite(roue_gauche,230 );
    delay(10);
    }
  if (analogRead(potentiometre_direction) >1000 && analogRead(potentiometre_direction) < 1023)
    { analogWrite(roue_droite,0 );
    analogWrite(roue_gauche, 255);
    delay(10);
    }
}

Schematics

Fritzing schematic
robot_control.fzz
Fritzing image
Robot control bb

Comments

Similar projects you might like

MeArm Robot Arm - Your Robot - V1.0

Project tutorial by Benjamin Gray

  • 19,311 views
  • 3 comments
  • 35 respects

Controlling a Robot with a PlayStation Controller

Project tutorial by Andrew R Gross and Jonathan Gross

  • 2,836 views
  • 0 comments
  • 7 respects

Make your first Arduino robot - The best beginners guide!

Project tutorial by Muhammed Azhar

  • 44,134 views
  • 15 comments
  • 98 respects

Smartphone Controlled Arduino 4WD Robot Car

Project in progress by Andriy Baranov

  • 53,727 views
  • 43 comments
  • 100 respects
Add projectSign up / Login