How to make programs

hello 

 

i need help with my elisa3 robot programing. i have problems making my robot follow the black line. can you help me with this. with the ADC using arduino programing. 

 

thanks 

hey whatsup man ? how can I

hey whatsup man ? how can I help you

need more info…

What’s your code look like so far? What are you using for sensors. I assume you have two motors driving the robot differentially.

yes the robot use two motors

yes the robot use two motors to drive it.

So a little trick for line

So a little trick for line followers that have analog inputs. Turns out you only need one sensor to follow the line. Typical light sensors don’t drop off quickly as they run off the line. They see the edge of the line as a gray area.

So try this

1.       assuming black is a low value and white is a high value

2.       Pick one of the inner sensors probably proximityResult[9]

3.       What value does it when you’re completely off the line, I’m assuming a white area. Call this maxProxReslt.

4.       What value does it give you when it’s completely on the line, assuming the line is black. Call this minProxReslt.

5.       The mid-point is (minProxReslt + maxProxReslt)/2

6.       Your left threshold is mid-point – 10%

7.       Your right threshold is mid-point +10%

8.       If (proximityResult[9] > mid-point – 10% && proximityResult[9] < mid-point + 10% ) go strait

9.       (You may have to swat the direction of the next two depending on how your light sensors respond to the environment your running in)

10.   If (proximityResult[9] < mid-point – 10%) turn right

11.   If (proximityResult[9] > mid-point – 10%) turn left

12.   If your robot is completely off the line it will continue turning till it finds the line again.

It’s a start, it will get you following the line.

Note if the line is too thin or the robot travels to fast sticking to the line becomes more difficult. And the robot will start to “wobble” the line.

 

** void thresholds(){ if**

 

void thresholds(){

 

  if (line[0] >756){

  line[0] = true;  }

    else { 

     line[0] = false;}

 

   if (line[1] >920){

  line[1] = true;}

     else { 

   line[1] = false;}

 

    if (line[2] >915){

  line[2] = true;}

      else { 

   line[2] = false; }

 

   if (line[3] >700){

  line[3] = true;}

       else { 

   line[3] = false;}

}

 

 

 

void linefollowing()

{

if (!line[0] && !line[3]&& line[1] && line[2])

{leftMotorForward(20);

  rightMotorForward(20);

  }

 

 

   else if (line[0] && line[1]&& !line[2] && !line[3])

{leftMotorForward(20);

  rightMotorForward(15);

   }

 

   else if (!line[0] && !line[1]&& line[2] && line[3])

{leftMotorForward(20);

  rightMotorForward(15);

  }

 

}

Does that work for you?

Hmm.

We need a better way to post code snippets.

-Rich

 

how to make it better?

how to make it better?