printing joystick when active

Dependencies:   mbed

Revision:
2:79baf68e700e
Parent:
1:9c6ad6449efd
Child:
3:08df357719f2
--- a/main.cpp	Tue May 04 08:36:13 2021 +0000
+++ b/main.cpp	Tue May 04 08:39:12 2021 +0000
@@ -1,3 +1,12 @@
+// 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
@@ -13,10 +22,12 @@
     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) {
@@ -29,7 +40,8 @@
         }
 
         if (joystickRight == 1) {
-            printf( "joystickRight is active \r\n");        
+            printf( "joystickRight is active \r\n");
+            wait(1);
         }
     }
 }