RoboCup Base Station
Dependencies: mbed mbed-rtos Wireless Drivers
Diff: main.cpp
- Revision:
- 1:e5373c63f642
- Parent:
- 0:a606cf2249ad
- Child:
- 2:7fd95eae5731
--- a/main.cpp Wed Dec 31 02:45:31 2014 +0000 +++ b/main.cpp Wed Dec 31 03:33:35 2014 +0000 @@ -11,6 +11,8 @@ // To show that the mbed is running DigitalOut status_led(LED1); +DigitalOut r2_led[3] = {p24, p25, p26}; // TX, RX, ERR + // Function for writing a number to the 7-segment display void writeSegment(uint8_t val) { @@ -25,25 +27,44 @@ int main() { + // turn all LEDs off initially + for (int i=0; i<3; i++) + r2_led[i] = 1; + latch = 0; // initialize the latch pin for the CD4511B decoder status_led = 0; // initialize & turn off led for startup operations uint8_t channel; // limit to 4 bits (0x00 to 0x0F) channel = 8; // light up all of the 7-segment's segments at startup - allows for the user to detect if there's a problem writeSegment(channel); - wait(1.0); // wait 2 seconds to ensure user sees the startup operation + channel = 0; // start back over at 0 + + wait(0.2); - channel = 0; // start back over at 0 + // turn on all secondary radio status LEDs + for (int i=2; i>=0; i--) { + r2_led[i] = 0; + wait(0.2); + } + + // hold + wait(0.3); + + // turn off all secondary radio status LEDs + for (int i=0; i<3; i++) { + r2_led[i] = 1; + wait(0.2); + } while(1) { // send numerical value to 7-segment & hold for a while writeSegment(channel++); wait(0.3); status_led = !status_led; - + // wait again just so that the status led and segment are out of sync wait(0.2); - + // reset value if too high channel = channel > 9 ? 0 : channel; }