Tina Dokic
/
i2c-_pins_tinf_06-10-2020
tinf
Diff: main.cpp
- Revision:
- 0:5ca7c8550369
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 06 17:25:44 2020 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" + + +class MyClassB +{ +public: + MyClassB(PinName sda, PinName scl): _i2c (sda, scl) + { + _result =0; + }// I2C Pins übergeben p28, p27 + float read(); + +private: + I2C _i2c; + float _result; +}; + +float MyClassB :: read(){ + return _result; +} + + + +MyClass myClass(0.0); +MyClassB sensor(p28, p27); + +int main() +{ + myClass.status(); + wait_ms(500); + + printf("Sensorwert: %f\n", sensor.read()); + +} \ No newline at end of file