RoboCup Base Station
Dependencies: mbed mbed-rtos Wireless Drivers
main.cpp
- Committer:
- jjones646
- Date:
- 2014-12-31
- Revision:
- 1:e5373c63f642
- Parent:
- 0:a606cf2249ad
- Child:
- 2:7fd95eae5731
File content as of revision 1:e5373c63f642:
// Cycle through a 7-segment LCD display #include "mbed.h" // Outputs used as input values to the 7-segment binary decoder DigitalOut signal[4] = {p17, p18, p19, p20}; // For latching the 7 segment led's output DigitalOut latch(p16); // 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) { // write out the new value for (int i=0; i<4; i++) signal[i] = ((1<<i) & (val)) & 0x0F; // latch the value for (int i=0; i<2; i++) latch = !latch; } 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); channel = 0; // start back over at 0 wait(0.2); // 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; } }