first commit

Dependencies:   mbed

Revision:
2:65f24e5a3ce4
diff -r 0ab6ec2cda59 -r 65f24e5a3ce4 MyClassB.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyClassB.h	Tue Oct 06 17:22:26 2020 +0000
@@ -0,0 +1,23 @@
+
+class MyClassB 
+{
+    public:
+        MyClassB(PinName sda, PinName scl) : i2c(sda, scl) {};  // I2C Pins übergeben p28, p27
+        float read(); 
+  
+    private:
+        I2C i2c;
+};
+
+float MyClassB::read()
+{
+    const int addr = 0x90;
+    char cmd[2];
+    i2c.write(addr, cmd, 2);
+    wait(0.5);
+    cmd[0] = 0x00;
+    i2c.write(addr, cmd, 1);
+    i2c.read(addr, cmd, 2);
+    float tmp = (float((cmd[0]<<8)|cmd[1]) / 256.0);
+    return tmp;
+}
\ No newline at end of file