Go Down

Topic: Beta Line Follower whit Android device done.. and now? (Read 1 time) previous topic - next topic

SebastianMelmot

6 month ago 2 my friends and me created a bot based on Arduino and an Android Device, this use camera of the smartphone and Open CV Library for recognise the line and a Matematical expression based on Fuzzy Logich for choose the best way to follow. Here you can see the beta version of our bot: https://www.youtube.com/watch?v=93oYoxNfIzU .  what do you think about it?

Now i restart to work on it and would ask to you, what i can improve in my bot?
have you any suggestions for me?
How i can improve my alghoritm or what i can add on my bot ?

StanD

Looks pretty good, well done!

As for ideas for improvement:

  • Make it go faster and still track the line

  • Maybe have the camera pointed further away (zoom out a bit) so that you can plan movement better.

  • Test it out on a more complex course with sharp turns and line breaks



Check out some of the YouTube videos of the Polulu 3pi robot. These things are zipping around!
Arduino experiments, resources and hacks http://42bots.com

dearsmith2




I am mechlogy please help me , i have no idea how to change it. i have line follower robot , and i want to operate my robot by blutooth , i want start and stop my line follower robot by blutooh ,my line follower robot code is
 
//code is

int rightmotor1=12;
int leftmotor1=13;
int rightmotor2=9;
int leftmotor2=8;


int sensorleft=5;
int sensorcenter=6;
int sensorright=7;


int l1=1;
int l2=1;
int l3=1;

int f1=0;
int f2=0;
int f3=0;

//////////////////////////////////////

void setup()
{

 pinMode(rightmotor1,OUTPUT);
 pinMode(leftmotor1,OUTPUT);
 pinMode(rightmotor2,OUTPUT);
 pinMode(leftmotor2,OUTPUT);

 pinMode(sensorleft,INPUT);
 pinMode(sensorcenter,INPUT);
 pinMode(sensorright,INPUT);

}
///////////////////////////////////////////////////

void loop()
{
l1=digitalRead(sensorleft);
l2=digitalRead(sensorcenter);
l3=digitalRead(sensorright);

/////////////////////////////////////////////////////////////////////
if(l1==1&&l2==1&&l3==1)   //feedback when comes all sensor on white
{
l1=f1;
l2=f2;
l3=f3;
}

////////////////////////////////////////////////////////////////////////////
if(l1==0&&l2==1&&l3==1||l1==0&&l2==0&&l3==1)   //left turn
{
  digitalWrite(rightmotor1,1);
  digitalWrite(rightmotor2,0);
  digitalWrite(leftmotor1,0);
  digitalWrite(leftmotor2,0);
}
else
if(l1==1&&l2==1&&l3==0||l1==1&&l2==0&&l3==0)  //right turn
{
  digitalWrite(rightmotor1,0);
  digitalWrite(rightmotor2,0);
  digitalWrite(leftmotor1,1);
  digitalWrite(leftmotor2,0);
}
else
if(l1==1&&l2==0&&l3==1)  //go forward straight
{
  digitalWrite(rightmotor1,1);
  digitalWrite(rightmotor2,0);
  digitalWrite(leftmotor1,1);
  digitalWrite(leftmotor2,0);
}
else
if(l1==0&&l2==0&&l3==0) //stop
{
  digitalWrite(rightmotor1,0);
  digitalWrite(rightmotor2,0);
  digitalWrite(leftmotor1,0);
  digitalWrite(leftmotor2,0);
  delay(2000);
   digitalWrite(rightmotor1,1);
  digitalWrite(rightmotor2,0);
  digitalWrite(leftmotor1,1);
  digitalWrite(leftmotor2,0);
 
}

///////////////////////////////////////////////////////////////////
f1=l1;
f2=l2;
f3=l3;        //memory variables
////////////////////////////////////////////////////////////////////
} ,





i want to keep all code in function and want to call in blutoooh code


i want my robot start and stop by blutooth please help me
my blutooth code is

#include <SoftwareSerial.h>


SoftwareSerial mySerial(10, 11); // RX, TX
String state;// string to store incoming message from bluetooth
int  LED = 5; // LED on pin 13

void setup() {
 mySerial.begin(9600);
 Serial.begin(9600); // serial communication to check the data on serial monitor
   pinMode(LED, OUTPUT);

 mySerial.println("Welcome to the wonderful world of bluetooth communication");
  delay(1000);
  mySerial.println("Sending a '1' will turn on the LED, Sending a '0' will turn off the LED");
  delay(1000);
  mySerial.println("a '3' will flash the LED and a '4' will kick out a lot of data from the LDR");


}
//-----------------------------------------------------------------------// 
void loop() {
  while (mySerial.available()){  //Check if there is an available byte to read
  delay(10); //Delay added to make thing stable
  char c = mySerial.read(); //Conduct a serial read
  state += c; //build the string- either "On" or "off"
  } 
  if (state.length() > 0) {
    Serial.println(state);


  if(state == "turn on")
  {
    digitalWrite(5, HIGH);
   
      }
 
  else if(state == "turn off")
  {
    digitalWrite(5, LOW);
     }
     else if(state == "turn1 on")
  {
    digitalWrite(5, HIGH);
   
      }
 
  else if(state == "turn2 off")
  {
    digitalWrite(5, LOW);
     }
 
 
state ="";}} //Reset the variable



 

i am using arduino atmega2560 and blutooth hc 06 l298n


dearsmith2

through android i want my line follow robot stop and start . please help me ,

PaulS

Quote
please help me ,
You need to help yourself. YOU need to recognize what part of the second mis-posted code deals with the bluetooth device. YOU need to recognize what part(s) of that code read the data. You need to recognize what parts of that code are absolute nonsense (here's a hint: It's the stupid delay() call; it does NOT make anything more stable). You need to recognize what part(s) of that code are making decisions based on the received data.

Then, you need to dump the code that actually does what the serial data says should be done, and replace it with code from the first sketch. It would be far easier if the second code had functions with meaningful names.

YOU need to make an honest attempt to learn something. Or, you need to change your tag line to "We just hunt around in the internet and try to find someone to do the work for free that we overcharge you for..."

Go Up