1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
DudeHD
Date:
Thu Dec 06 17:10:19 2018 +0000
Child:
1:3912c97cd689
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:19 2018 +0000
@@ -0,0 +1,22 @@
+#include "mbed.h"
+I2C senzor(p28,p27);
+Serial pc(USBTX, USBRX);
+int main() {
+    int adr =0b10010000; //adresa senzora, naci u datasheetu
+    int point=0b00000000;
+    short t_int; //temp. kao 16-bitni podatak
+    float temp; //izracunata temperatura
+    char data[2]; //temperatura se vraca kao 16-bitni podatak
+    senzor.frequency(100000)
+    while(1) {
+        senzor.write(adr,&point,1,true);
+        senzor.read(adr,data,2,false);
+        t_int=(data[0]<<8 || data[1];)>>5;
+        temp=t_int*0.125;
+        //obrada primljenog podatka (short) tako da se dobije decimalna
+        //vrijednost temperature (float); ovdje napišite c++ kod gore
+        //napisanog pseudokoda
+        pc.printf("Temperatura: %.3f\n", temp);
+        wait(1);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Dec 06 17:10:19 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file