Long Range Maze Solving Line Follower

Hello guys this is me Noah and my first robot project on here. It is a wooden robot cut with a jigsaw and I used a drill and screws to add the motors, the caster, and the arduino to the robot.Right now all the robot does is move around without encoders or sensors. It used to have a webcam but I am using it for another bot.

The robot will eventually be a super long range line following robot. It will be if it was capable of following a line able to go miles and miles without charging as long as it doesn't break. Although there are some problems with the wheels becasue the tires on the wheels slip easily against the tire holder itself I can work it out.

If anybody has any ideas for how I can test a robot that can solve a maze miles long message me or reply below. Thanks!!! Wish me good luck!!!

UPDATE:  6/5/2016

The robot's arduino code is finally working. The robot now can move forward, backwards, CW, and CCW without a hitch with the help of encoders. I will be posting a video on youtube soon. Stay tooned!!!

UPDATE: 6/20/2016

Hey guys just letting you know I am salvaging the robot for parts. I need the processor and motor drivers for my trinity robot. I will post something else on here instead. Stay tuned!!!

This is a video of my robot going around in circles on youtube.

#include <Encoder.h>
Encoder LeftEncoder(19,18);// Left encoder is attached to pins 19 and 18 on arduino mega
Encoder RightEncoder(20,21);//Right Encoder is attached to pins 20 and 21 on arduino mega
const int LeftMotorDir = 2;//Is a digital pin when if high or low changes the direction of left motor. High is forward low is reverse.
const int LeftMotorPWM = 3;//Left motor speed pin controlled by pwm
const int RightMotorDir = 4;//Is a digital pin when if high or low changes the direction of right motor. High is forward low is reverse.
const int RightMotorPWM = 5;//Right motor speed pin controlled by pwm
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(LeftMotorDir, OUTPUT);
  pinMode(LeftMotorPWM, OUTPUT);
  pinMode(RightMotorDir, OUTPUT);
  pinMode(RightMotorPWM, OUTPUT);
 
}

void loop() {
  // put your main code here, to run repeatedly:
Stop();//Stops robot and sets encoders to zero
Move(255, 20000, 255, 20000);//Moves robot forward at 20000 ticks on the encoder at 255 or max speed
delay(1000);// Stops for 1000 miliseconds
Stop();
Move(255, -20000, 255, 20000);
delay(1000);
Stop();
Move(255, 20000, 255, -20000);
delay(1000);
Stop();
Move(255, -20000, 255, -20000);
delay(1000);
}
void Move(int LeftSpeed, int LeftDistance, int RightSpeed, int RightDistance)
{
  long LeftRead, RightRead;//Left and right encoder read variables made here
  LeftRead = LeftEncoder.read();//LeftRead is reading the left encoder
  RightRead = RightEncoder.read();//RightRead reads the right encoder
  if(LeftDistance > 0 && LeftRead < LeftDistance)//If LeftDistance a positive value and LeftRead is smaller than it move robot forward
  {
    analogWrite(LeftMotorPWM, LeftSpeed);
    digitalWrite(LeftMotorDir, HIGH);
  }
  if(LeftDistance < 0 && LeftRead > LeftDistance)//If LeftDistance a negative value and LeftDistance is smaller than LeftRead move backwards
  {
    analogWrite(LeftMotorPWM, LeftSpeed);
    digitalWrite(LeftMotorDir, LOW);
  }
  if ((LeftDistance > 0 && LeftRead >= LeftDistance) || (LeftDistance < 0 && LeftRead <= LeftDistance) || (LeftDistance == 0))// If LeftDistance equivalent to nothing or LeftRead greater than LeftDistance while LeftDistance is a possitive value or the opposite for left motor stop left motor
  {
    digitalWrite(LeftMotorPWM, LOW);
    digitalWrite(LeftMotorDir, LOW);
  }
  if(RightDistance > 0 && RightRead < RightDistance)//If RightDistance a positive value and RightRead is smaller than it move robot forward
  {
    analogWrite(RightMotorPWM, RightSpeed);
    digitalWrite(RightMotorDir, LOW);
  }
  if(RightDistance < 0 && RightRead > RightDistance)//If RightDistance a negative value and RightDistance is smaller than RightRead move backwards
  {
    analogWrite(RightMotorPWM, RightSpeed);
    digitalWrite(RightMotorDir, HIGH);
  }
  if ((RightDistance > 0 && RightRead >= RightDistance) || (RightDistance < 0 && RightRead <= RightDistance) || (RightDistance == 0))// If RightDistance equivalent to nothing or RightRead greater than RightDistance while RightDistance is a possitive value or the opposite for right motor stop right motor
  {
    digitalWrite(RightMotorPWM, LOW);
    digitalWrite(RightMotorDir, LOW);
  }
}
void Stop()//Stop robot and set encoder value to zero
{
  analogWrite(RightMotorPWM, 0);
  analogWrite(LeftMotorPWM, 0);
  LeftEncoder.write(0);
  RightEncoder.write(0);
}

 

Comments

Submitted by JeffRo on Sun, 2016-05-22 09:31

JeffRo's picture

It is always the first Robot that is the hardest, once you get a design down and software the rest are easier. I dont know much about arduino so I am no help there. You need to decide what you want your bot to do. Roam around, follow a line, Follow Light etc... Then next you can determine what way to proceed with your hardware and software. I will be glad to help in any way I can.

Submitted by nschreiber0813 on Sun, 2016-05-22 09:41

nschreiber0813's picture

Dear: JeffRo

Thanks for your help!!! Thanks for your nice comment as well!!! Do you have a more practical use for it? I want this robot to serve me something. Thanks!!!

From: Noah

Submitted by Roxanna77 on Sun, 2016-05-22 09:57

Roxanna77's picture

Welcome to CKR Noah!
I like the wood base, leaves you open to lots of options mounting stuff, and no chance of shorting out!
On my BRP, the aluminum frame is a bit scary... have to be so careful mounting things and moving wires.
Looks great, looking forward to its progress.

Submitted by nschreiber0813 on Sun, 2016-05-22 10:03

nschreiber0813's picture

Dear: Roxy

Thanks!!! What robot was that you were talking about? Also what is BRP? Thanks!!! I love this site!!!

From: Noah

Submitted by Roxanna77 on Sun, 2016-05-22 17:19

Roxanna77's picture

Mr. Noah,

My Big Robot Project.... someday I might actually finish it!

http://coolkidsrobots.com/robot/big-robot-project-brp

 

 

Submitted by nschreiber0813 on Tue, 2016-05-24 18:47

nschreiber0813's picture

Dear: Roxy

Good luck with it!!! Awesome!!!

From: Noah

Submitted by Roxanna77 on Mon, 2016-06-20 22:07

Roxanna77's picture

I prefer set aside... but I am guessing your new laser cut chassis is taking focus

 

~Roxy~
"Propeller Girl"
I tinker, therefore I am.....

Submitted by nschreiber0813 on Wed, 2016-06-22 21:13

nschreiber0813's picture

Yeah it is and thanks!!!