Bitweise schieben via Joystick

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Ursukar
Date:
Mon Dec 02 18:28:02 2019 +0000
Commit message:
Bitschieben mit Joystick

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 9db80233bfe2 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 02 18:28:02 2019 +0000
@@ -0,0 +1,48 @@
+#include "mbed.h"
+
+//Alle Buttons am Joystick definieren
+DigitalIn ButtonDown(p12);
+DigitalIn ButtonLeft(p13);
+DigitalIn ButtonCenter(p14);
+DigitalIn ButtonUp(p15);
+DigitalIn ButtonRight(p16);
+
+BusOut myleds(LED1, LED2, LED3, LED4);
+void Reset(uint8_t mask);
+void bitLeft();
+/*
+void print_binary(uint8_t x) {  // function to print binary
+    for(int i=sizeof(x)<<3; i; i--)
+        putchar('0'+((x>>(i-1))&1));
+}*/
+
+int main()
+{
+    uint8_t mask = 0b00001111;
+
+    //bool lastButtonstate;
+    while(1) 
+    {
+        if(ButtonCenter) 
+        {
+            Reset(mask);
+        }
+        if(ButtonLeft) 
+        {
+            bitLeft();
+        }
+    }
+}
+
+void Reset(uint8_t mask)
+{
+    myleds = mask;
+}
+
+void bitLeft()
+{
+
+    myleds = myleds << 1;
+    wait_ms(500);
+
+}
\ No newline at end of file
diff -r 000000000000 -r 9db80233bfe2 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Dec 02 18:28:02 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file