Version finale

Dependencies:   mbed

Fork of Main_V3_Old by EI2I_4_projet_1_2017-2018

Revision:
4:784c4b53a3d4
Parent:
3:534235b99bc6
Child:
5:ae57f8977663
--- a/main.cpp	Mon Oct 02 12:47:09 2017 +0000
+++ b/main.cpp	Mon Oct 02 13:20:42 2017 +0000
@@ -1,19 +1,52 @@
 #include "mbed.h"
-
+#include "DS18B20.h"
+#include "OneWireDefs.h"
 #include "TSL2561.h"
+//------------------------------------
+// Hyperterminal configuration
+// 9600 bauds, 8-bit data, no parity
+//------------------------------------
 
 
-//Déclaration variables
-TSL2561 LUM(PB_7,PB_6); // Luminosité (I2C:SDA,SCL)
+//#define THERMOMETER DS18S20
+#define THERMOMETER DS18B20
+
+Serial serie(SERIAL_TX, SERIAL_RX);
+TSL2561 LUM(PB_7, PB_6); // Luminosité (I2C:SDA,SCL)
 AnalogIn Humidite(PA_0);
 Serial PC(PA_2, PA_3);
-
-int main() {
+DigitalOut myled(LED1);
 
-    while(1) {
-            printf("Lum: %f \r\n", LUM.lux());
-            printf("Hum: %f \n\r",Humidite.read());
-          
+int main()
+{   
+    
+    int i = 1;
+    serie.printf("Hello World !\n");
+     // device( crcOn, useAddress, parasitic, mbed pin )
+    THERMOMETER device(true, true, false, D3);
+    
+    while (!device.initialize());    // keep calling until it works
+    
+    while (true)
+    {   
         wait(1);
+        serie.printf("This program runs since %d seconds.\n", i++);
+        myled = !myled;
+        printf("Lum: %f \r\n", LUM.lux());
+        printf("Hum: %f \n\r",Humidite.read());
+        // changing the resolutions only affects the DS18B20. The DS18S20 is fixed.
+        device.setResolution(nineBit);
+        device.readTemperature(); 
+        wait(2);
+        device.setResolution(tenBit);
+        device.readTemperature(); 
+        wait(2);
+        device.setResolution(elevenBit);
+        device.readTemperature(); 
+        wait(2);
+        device.setResolution(twelveBit);
+        device.readTemperature(); 
+        wait(2);
     }
-}
\ No newline at end of file
+    return EXIT_SUCCESS;
+}