1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
DudeHD
Date:
Thu Dec 06 17:10:52 2018 +0000
Commit message:
1

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	Thu Dec 06 17:10:52 2018 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+//master program 3
+BusInOut ledout(p21,p22,p23,p24);
+BusInOut ledice(LED4,LED3,LED2,LED1);
+BusInOut datain(p20,p19,p18,p17);
+I2C i2c_port(p28, p27);
+int main() {
+    ledice.output();
+    ledout.output();
+    datain.input();
+    datain.mode(PullUp);
+    int adr = 0x50; //adresa slavea, 7-bitna
+    char data_out, data_in; //poslani, primljeni podatak
+    i2c_port.frequency(100000); //brzina prijenosa, bit/s
+    while(1) {
+        ledice=datain;
+        data_out=datain;
+        i2c_port.write(adr << 1,&data_out,1,true);
+        i2c_port_read(adr<<1,&data_in,1,false);
+        ledout=data_in;
+        wait_us(1000);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Dec 06 17:10:52 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file