Voor jan

Dependencies:   mbed

Revision:
0:a0d1e66e78aa
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 17 09:52:40 2018 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+
+class TMP36
+{
+public:
+    TMP36(PinName pin);
+    TMP36();
+    operator float ();
+    float read();
+private:
+    AnalogIn A0;
+};
+ 
+TMP36::TMP36(PinName pin) : A0(pin){}
+TMP36::operator float ()
+{
+    return ((A0.read()*3.3)-0.500)*100.0 + 1.2;
+}
+TMP36 myTMP36(A0);
+
+int main()
+{
+    float tempC;
+    float ta[10];
+    float temperatuur;
+
+    
+    while(1) {
+ 
+        tempC = myTMP36;
+        temperatuur = 0;
+        for (int i =0; i<10; i++)
+        {
+            ta[i] = float(myTMP36);
+            temperatuur += ta[i];
+        }
+        temperatuur /= 10;
+        printf(" T=%5.2F C \n\r", temperatuur);
+       
+        wait(1);
+    }
+}
\ No newline at end of file