X

Project 2: Line following bot

Release Candidate
Very hard to keep it steady as voltage increases. That’s the best speed/stability result I got so far. Now using 3 sensors.
The video below has it running at about 6V.


Test 1
With differential steering


This is the project in a very early stage with a regular RC toy steering mechanism.

Using 2 IR sensors to detect change in color and correct direction. It’s pretty rough right now and it overshoots all the time. Not the best hardware… No word about software (don’t want to blame myself 🙂 )

Bare steering logic (RC toy version)

[code language=”cpp”]
void loop() {

valLeft = analogRead(clrLeft);
valRight = analogRead(clrRight);
Serial.print(valLeft);
Serial.print(“-“);
Serial.print(valRight);
error = valRight – valLeft;
Serial.print(“-“);
Serial.print(error);

if (valLeft lostTime + 1000) // Lost for too long
{
moving = false;
analogWrite(mtrFwdPin,0); // Stop
lostTime = millis();
}
}
Serial.print(“-Lost:”);
Serial.print(lostTime);
Serial.print(“-ms:”);
Serial.print(millis());

}
else
{
lostTime = 0;
moveForward(130);

// It seems like PID algorithm is the way to go
// (when I get my motor for differential steering)
// Below a poor math man’s algorithm for a regular RC car steering mechanism
if (abs(error) > errorTarget)
{
if (error > 0)
{
digitalWrite(right,LOW);
digitalWrite(left,HIGH);

dir = “—>—“;
}

if (abs(error)

Wagner: