Soccer Robot C - Basic lessons - Signal ball caught
This exercise will help You using ML-R 8x8 bicolor display, CAN Bus,UART, 4 switches and will be useful for RCJ Soccer competition, too.
Task: signal barrier interrupted.
The robot doesn't move. Each time barrier is interrupted, display "Y". Otherwise, display "N", using ML-R 8x8 bicolor display, CAN Bus,UART, 4 switches.
Solution
void RobotSoccer::loop() {
if (analogRead(35) < 500)
sign(89); // Y
else
sign(78); // N
delayMs(1);
}
78 and 89 are ASCII codes for "N" and "Y". "delayMs(1)" is here to slow down the loop a little bit, so that it doesn't overload CAN Bus with too many messages. Notice that this is not the best way to do it, though it is the simplest one, as the program constantly sends the display command to display a letter, despite the fact that this letter may already be displayed.