uebung3

Dependencies:   mbed

Committer:
rob117
Date:
Tue Oct 06 17:16:02 2020 +0000
Revision:
1:e637acc46823
Parent:
0:97326dde09e8
uebung3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rob117 0:97326dde09e8 1 #include "mbed.h"
rob117 0:97326dde09e8 2
rob117 0:97326dde09e8 3
rob117 0:97326dde09e8 4
rob117 0:97326dde09e8 5
rob117 0:97326dde09e8 6 class MyClassB {
rob117 0:97326dde09e8 7
rob117 0:97326dde09e8 8 public:
rob117 0:97326dde09e8 9 MyClassB(PinName sda, PinName scl) : i2c(sda, scl){
rob117 0:97326dde09e8 10
rob117 0:97326dde09e8 11 result = 0;
rob117 0:97326dde09e8 12 }
rob117 0:97326dde09e8 13 float read();
rob117 0:97326dde09e8 14
rob117 0:97326dde09e8 15 private:
rob117 0:97326dde09e8 16 I2C i2c;
rob117 0:97326dde09e8 17 float result;
rob117 0:97326dde09e8 18
rob117 0:97326dde09e8 19
rob117 0:97326dde09e8 20 };
rob117 0:97326dde09e8 21
rob117 0:97326dde09e8 22 float MyClassB::read(){
rob117 0:97326dde09e8 23 return result;
rob117 0:97326dde09e8 24 }
rob117 0:97326dde09e8 25
rob117 0:97326dde09e8 26
rob117 0:97326dde09e8 27 MyClassB sensor(p28, p27);
rob117 0:97326dde09e8 28
rob117 0:97326dde09e8 29
rob117 0:97326dde09e8 30 int main() {
rob117 0:97326dde09e8 31 while(1) {
rob117 0:97326dde09e8 32
rob117 0:97326dde09e8 33 wait(500);
rob117 0:97326dde09e8 34 printf("Wert: %f \n", sensor.read());
rob117 0:97326dde09e8 35 }
rob117 0:97326dde09e8 36 }