Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. // Include the libraries we need
  2. #include <OneWire.h>
  3. #include <DallasTemperature.h>
  4. #include <MultiFuncShield.h>
  5.  
  6. // Data wire is plugged into port A4 on the Arduino
  7. #define ONE_WIRE_BUS A4
  8.  
  9. // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
  10. OneWire oneWire(ONE_WIRE_BUS);
  11.  
  12. // Pass our oneWire reference to Dallas Temperature.
  13. DallasTemperature sensors(&oneWire);
  14.  
  15. /*
  16. * The setup function. We only start the sensors here
  17. */
  18. void setup(void)
  19. {
  20. // start serial port
  21. Serial.begin(9600);
  22. Serial.println("Dallas Temperature IC Control Library Demo");
  23.  
  24. // Start up the library
  25. sensors.begin();
  26.  
  27. Timer1.initialize();
  28. MFS.initialize(&Timer1);
  29. }
  30.  
  31. /*
  32. * Main function, get and show the temperature
  33. */
  34. void loop(void)
  35. {
  36. // call sensors.requestTemperatures() to issue a global temperature
  37. // request to all devices on the bus
  38. Serial.print("Requesting temperatures...");
  39. sensors.requestTemperatures(); // Send the command to get temperatures
  40. Serial.println("DONE");
  41. // After we got the temperatures, we can print them here.
  42. // We use the function ByIndex, and as an example get the temperature from the first sensor only.
  43. Serial.print("Temperature for the device 1 (index 0) is: ");
  44. Serial.println(sensors.getTempCByIndex(0));
  45. MFS.write(sensors.getTempCByIndex(0),2);
  46. delay(10);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement