AEWS / Mbed 2 deprecated I2C_prototyp

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
sjpabury
Date:
Tue May 08 09:43:12 2018 +0000
Commit message:
Erstes Testprogramm zum I/O Expander (I2C)

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue May 08 09:43:12 2018 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+
+I2C i2c(p28, p27);
+DigitalIn button(p20);
+
+const int addr = 0b01000000;
+char cmd_output[2];
+char cmd_input[2];
+char input;
+int num[] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
+
+int main() {
+    cmd_output[0]=0x06;
+    cmd_output[1]=0x00;
+    cmd_input[0]=0x07;
+    cmd_input[1]=0b00001111;
+    i2c.write(addr, cmd_output, 2);
+    i2c.write(addr, cmd_input, 2);
+    cmd_output[0]=0x02;
+    cmd_input[0]=0x01;
+    while(1) {
+        
+        if(button)
+        {
+            input = i2c.read(addr, cmd_input, 2);
+            
+            cmd_output[1]=num[input];
+            i2c.write(addr, cmd_output, 2);
+            wait(0.2);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue May 08 09:43:12 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file