test program

Dependencies:   mbed

Revision:
5:d65703f7a282
Parent:
4:cfc02c02dd97
--- a/main.cpp	Mon Jan 13 17:49:52 2020 +0000
+++ b/main.cpp	Mon Jan 13 17:53:34 2020 +0000
@@ -2,6 +2,7 @@
 #define BUTTON1 p14      // M3: push joystick pin
 // #define BUTTON1 A1       //NUCLEO: Taster A1
 
+int modifyBit(int x, unsigned char position, bool State);
 int lauflicht(bool richtung, int time, int &anz);
 void nibbleLeds(int value);
 void printb(uint8_t x);
@@ -20,9 +21,17 @@
     
     nibbleLeds(value);
     printb(value);
+    value = modifyBit(value, 2, 1);
+    printb(myleds);
+    printb(modifyBit(INIT, 3, 1));
     wait(0.1); 
 }
 
+int modifyBit(int x, uint8_t position, bool State) {
+    int mask = 1 << position;
+    int state = int(State);
+    return (x & ~mask) | ((state << position) & mask);   
+}
 
 int lauflicht(bool richtung, int time, int &anz) {
     int i;