stephen reidy
/
Lab1_bounce
printing joystick when active
main.cpp
- Committer:
- stephensv650
- Date:
- 2021-05-04
- Revision:
- 3:08df357719f2
- Parent:
- 2:79baf68e700e
File content as of revision 3:08df357719f2:
// A) original code committed (without delays) // B) Yes, as the micro controller runs through the while loop it checks for active ststments. // this is done much faster than a person can racct to. also there may be possible bouncing on the switch. // C) 1. Debounce, 2. capasitor, 3. timer, 4, delay, 5. possible clear screen // D) See modified code below. #include "mbed.h" // Stephen Reidy; lab1 InterruptIn joystickDown(p12); // joystick Down InterruptIn joystickLeft(p13); // joystick Left InterruptIn joystickCenter(p14); // joystick Center InterruptIn joystickUp(p15); // joystick Up InterruptIn joystickRight(p16); // joystick Right DigitalOut led(LED1); // LED 1 digital out int main() { while(1) { if (joystickDown == 1) { printf( "joystickDown is active \r\n"); wait(1); } if (joystickLeft == 1) { printf( "joystickLeft is active \r\n"); wait(1); } if (joystickCenter == 1) { printf( "joystickCenter is active \r\n"); wait(1); } if (joystickUp == 1) { printf( "joystickUp is active \r\n"); wait(1); } if (joystickRight == 1) { printf( "joystickRight is active \r\n"); wait(1); } } }