Jake Greaves
/
Laser_Maze_State_Machine
Laserzsssss
Revision 3:1c6031fd2b93, committed 2018-12-13
- Comitter:
- ADIJake
- Date:
- Thu Dec 13 14:25:43 2018 +0000
- Parent:
- 2:70e7b1b88824
- Commit message:
- Sean sucks;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Dec 13 10:07:48 2018 +0000 +++ b/main.cpp Thu Dec 13 14:25:43 2018 +0000 @@ -2,7 +2,7 @@ #define TERMINATOR '\n' #define SEPARATOR ',' -#define OFFSET 200 //mV +#define OFFSET 500 //mV #define RECEIVER_COUNT 5 #define BUTTON_COUNT 4 @@ -22,7 +22,7 @@ bool buttons_state[BUTTON_COUNT]; bool buttons_state_prev[BUTTON_COUNT] = {1, 1, 1, 1}; -AnalogIn solarCells[] = {PA_0, PA_1, PA_4, PB_0, PC_1}; +AnalogIn solarCells[] = {PC_1, PB_0, PA_4, PA_1, PA_0}; bool solarCellsState[RECEIVER_COUNT]; uint16_t solarCellsThreshold[RECEIVER_COUNT]; int active_receivers[RECEIVER_COUNT] = {0, 0, 0, 0, 0}; @@ -120,7 +120,7 @@ serial.printf("h"); } else { - for (int i = 0; i < 5; i++) { + for (int i = 0; i < 4; i++) { active_receivers[i] = 1; } serial.printf("x"); @@ -152,11 +152,17 @@ } }*/ - while(serial.getc() != "s"); - switch(state) { case IDLE: { - //serial.printf("State = IDLE\n\r"); + //serial.printf("State = IDLE\n\r"); + while(serial.getc() != 's'); + + for (uint8_t i = 0; i < RECEIVER_COUNT; i++) { + red_leds[i] = 0; + blue_leds[i] = 0; + green_leds[i] = 0; + } + while (buttonPressed == false) { for (uint8_t i = 0; i < BUTTON_COUNT; i++) { //serial.printf("Waiting for button...\n");