
RP6 ROBOT SYSTEM - 4. Programming the RP6
This macro sets the counter of stopwatch X to a given value.
Examples:
setStopwatch1(2324);
setStopwatch2(0);
setStopwatch3(2);
setStopwatch4(43456);
getStopwatchX()
This returns the counter level of stopwatch X.
Examples:
if(getStopwatch2() > 1000) { ... }
if(getStopwatch6() > 12324) { ... }
4.6.4. Status LEDs and Bumpers
void setLEDs(uint8_t leds)
This function allows you to control the 6 Status LEDs. Usage can be simplified with
binary constants instead of usual decimal numbers. Binary constants are formatted
like: 0bxxxxxx. The LEDs need 6 digits only.
Examples:
setLEDs(0b000000); // This deactivates all LEDs.
setLEDs(0b000001); // activates StatusLED1 and switches off all other LEDs.
setLEDs(0b000010); // StatusLED2
setLEDs(0b000100); // StatusLED3
setLEDs(0b001010); // StatusLED4 and StatusLED2
setLEDs(0b010111); // StatusLED5, StatusLED3, StatusLED2 and StatusLED1
setLEDs(0b100000); // StatusLED6
An alternative possibility the following:
statusLEDs.LED5 = true; // activate LED5 in the LED-register
statusLEDs.LED2 = false; // deactivate LED2 in the LED-register
updateStatusLEDs();
// commit the changes!
Here we activate StatusLED5 and deactivate StatusLED2, but we do not modify the
state of any other LED! This simplifies LED control from different program parts.
Attention:
statusLEDs.LED5 = true;
will NOT directly activate LED5! This command
will only set the corresponding bit in a variable! The LED5 will be illuminated after ex-
ecuting
updateStatusLEDs();
!
Two port-pins of the LEDs are additionally used to check the bumper status. In order
to read the bumpers, the controller will quickly switch the pin direction to input mode
and check if the connected microswitch is closed. We provide two functions for check-
ing the bumpers. The first function:
uint8_t getBumperLeft(void)
will read the left bumper status, whereas:
uint8_t getBumperRight(void)
will read the right bumper switch.
The Microcontroller executes these functions very fast and you will not see that the
- 86 -