Initialisierungslisten Uebung 1

Dependencies:   mbed

Committer:
Mr_Anderssson
Date:
Tue Oct 06 17:24:53 2020 +0000
Revision:
1:5f898b1088f7
Child:
2:32751b274adb
Uebung 3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mr_Anderssson 1:5f898b1088f7 1
Mr_Anderssson 1:5f898b1088f7 2 //Initialisieren - Erzeugen Sie in der folgenden Klasse mittel
Mr_Anderssson 1:5f898b1088f7 3 //Initialisierungsliste das I2C-Objekt mit p28, p27:
Mr_Anderssson 1:5f898b1088f7 4
Mr_Anderssson 1:5f898b1088f7 5 #include "mbed.h"
Mr_Anderssson 1:5f898b1088f7 6
Mr_Anderssson 1:5f898b1088f7 7 class MyClassB
Mr_Anderssson 1:5f898b1088f7 8 {
Mr_Anderssson 1:5f898b1088f7 9 public:
Mr_Anderssson 1:5f898b1088f7 10 MyClassB(PinName sda, PinName scl) : i2c(sda, sc1) // I2C Pins übergeben p28, p27
Mr_Anderssson 1:5f898b1088f7 11 {result=0;}
Mr_Anderssson 1:5f898b1088f7 12 float read();
Mr_Anderssson 1:5f898b1088f7 13
Mr_Anderssson 1:5f898b1088f7 14 private:
Mr_Anderssson 1:5f898b1088f7 15 I2C i2c;
Mr_Anderssson 1:5f898b1088f7 16 float result;
Mr_Anderssson 1:5f898b1088f7 17 };
Mr_Anderssson 1:5f898b1088f7 18
Mr_Anderssson 1:5f898b1088f7 19 float MyClass myClass (0.0);
Mr_Anderssson 1:5f898b1088f7 20 MyClassB sensor(p28, p27);
Mr_Anderssson 1:5f898b1088f7 21
Mr_Anderssson 1:5f898b1088f7 22 int main ()
Mr_Anderssson 1:5f898b1088f7 23 {
Mr_Anderssson 1:5f898b1088f7 24 printf("Sensorwert: %f \n", sensor.read())
Mr_Anderssson 1:5f898b1088f7 25 wait_ms(250);
Mr_Anderssson 1:5f898b1088f7 26 }