Update LineFollower authored by Markus Klinik's avatar Markus Klinik
This program is based on [this line follower Arduino project](https://create.arduino.cc/projecthub/Zubayer/easiest-line-follower-robot-635bc0). This program is based on [this line follower Arduino project](https://create.arduino.cc/projecthub/Zubayer/easiest-line-follower-robot-635bc0).
We translated their source code to SECA and made a couple of improvements.
A full explanation of the robot including discussion can be found in our paper. A full explanation of the robot including discussion can be found in our paper.
The robot has two motors and two sensors.
Sensors return a value between 0 and 1, and have no power draw.
Motors have three states, forward, backward, and stop.
In both forward and backward states, motors have a power draw of 750 mW.
We slightly changed the original source code to make it valid SECA, and made a couple of improvements.
- The sensors are read only once at the beginning of the loop - The sensors are read only once at the beginning of the loop
- The conditionals in the loop are mutually exclusive by way of nested if-else - The conditionals in the loop are mutually exclusive by way of nested if-else
- The loop exits and the robot stops when both sensors see black - The loop exits and the robot stops when both sensors see black
- TurnLeft is simplified. In the original version, the left motor turns backwards while the right motor turns forwards. We changed it so that the left motor stops and the right motor turns forwards. Similar for TurnRight. - TurnLeft is simplified. In the original version, the left motor turns backwards while the right motor turns forwards. We changed it so that the left motor stops and the right motor turns forwards. Similar for TurnRight.
From the diagrams it can be seen that if both motors are running, either forwards or backwards, the whole robot has a power draw of 1500 mW. If only one motor is running, the power draw is 750mW.
```c ```c
int main() { int main() {
int repeat = 1; int repeat = 1;
... ...
......