Então supostamente eu meto um código no Arduino que fará com que este receba certos valores dos sensores, certo?
Então depois onde vejo esses valores?
Será que é este o código?
1. void loop()
2. {
3. unsigned int sensors[3];
4. // get calibrated sensor values returned in the sensors array, along with the line position
5. // position will range from 0 to 2000, with 1000 corresponding to the line over the middle sensor
6. int position = qtr.readLine(sensors);
7.
8. // if all three sensors see very low reflectance, take some appropriate action for this situation
9. if (sensors[0] > 750 && sensors[1] > 750 && sensors[2] > 750)
10. {
11. // do something. Maybe this means we're at the edge of a course or about to fall off a table,
12. // in which case, we might want to stop moving, back up, and turn around.
13. return;
14. }
15.
16. // compute our "error" from the line position. We will make it so that the error is zero when
17. // the middle sensor is over the line, because this is our goal. Error will range from
18. // -1000 to +1000. If we have sensor 0 on the left and sensor 2 on the right, a reading of -1000
19. // means that we see the line on the left and a reading of +1000 means we see the line on
20. // the right.
21. int error = position - 1000;
22.
23. int leftMotorSpeed = 100;
24. int rightMotorSpeed = 100;
25. if (error < -500) // the line is on the left
26. leftMotorSpeed = 0; // turn left
27. if (error > 500) // the line is on the right
28. rightMotorSpeed = 0; // turn right
29.
30. // set motor speeds using the two motor speed variables above
31. }