Hello,
I'm working on a line follower for this map, that uses a TCRT5000 5 IR sensor array -
I'm not able to traverse the broad white strip and the black square after it, so I tried keeping track of the previous state of sensors and using it as a condition.
Eg-
If the robot went from a white strip to a case where the leftmost sensor detects black, it means the robot is on the broad strip but misaligned to the left. So, the robot turns to the right slightly to correct itself.
The problem is that this is not working, which I think is because the robot's momentum resulting in a previous State that is the same as current state, since the program loops quickly.
Here's how I coded the previous state tracker:
int previousState[5] = {0,0,0,0,0};
void setup() {.....}
void loop() {
//Reading Sensor Values
int s1 = digitalRead(ir1); //Left Most Sensor
int s2 = digitalRead(ir2); //Left Sensor
int s3 = digitalRead(ir3); //Middle Sensor
int s4 = digitalRead(ir4); //Right Sensor
int s5 = digitalRead(ir5); //Right Most Sensor
// -------- (Other code here)
int currentState[5] = {s1, s2, s3, s4, s5};
for (int i = 0; i < 5; i++)
{
previousState[i] = currentState[i];
}
}
Any idea how I can navigate those parts of the map, by correcting this program or using a different approach?
Thanks