Advertisement
Guest User

Arduino Temp

a guest
Oct 8th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <OneWire.h>
  2. #include <DallasTemperature.h>
  3. // Data wire is plugged into port 2 on the Arduino
  4. #define ONE_WIRE_BUS 2
  5. OneWire oneWire(ONE_WIRE_BUS);
  6. DallasTemperature sensors(&oneWire);
  7.  
  8. void setup(void)
  9. {
  10. // start serial port
  11. Serial.begin(9600);
  12. Serial.println("Dallas Temperatura Demo");
  13.  
  14. // Start up the library
  15. sensors.begin();
  16. }
  17.  
  18. void loop(void)
  19. {
  20. // call sensors.requestTemperatures() to issue a global temperature
  21. // request to all devices on the bus
  22. Serial.print("Leyendo temperaturas...");
  23. sensors.requestTemperatures(); // Send the command to get temperatures
  24. Serial.println(" Listo");
  25.  
  26. Serial.print("La Temperatura es: ");
  27. Serial.println(sensors.getTempCByIndex(0));
  28. delay(3000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement