/* Misura la temperatura con sensore DS18B20 collegato al piedino A0 --> 14 */ #include #include #define ONE_WIRE_BUS 14 OneWire ourWire(ONE_WIRE_BUS); DallasTemperature sensors(&ourWire); DeviceAddress Sump; float celsius = 0; // temperature variables float millivolts; //dichiarazione di variabile tensione (float è per i numeri con la virgola) void setup() { delay(1000); Serial.begin(9600); delay(1000); pinMode(13, OUTPUT); sensors.begin(); (!sensors.getAddress(Sump,0)); sensors.setResolution(Sump,12); // 12 bit } void loop() { //Serial.println(); sensors.requestTemperatures(); celsius= sensors.getTempCByIndex(0); Serial.println(celsius); delay(1000); if (celsius<25) { digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) } else { digitalWrite(13, LOW); // turn the LED off by making the voltage LOW } }