Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. #include <OneWire.h>
  2. #include <DallasTemperature.h>
  3. #include <Servo.h>
  4. Servo myservo;
  5. int val;
  6. int summe;
  7. // Data wire is plugged into port 2 on the Arduino
  8. #define ONE_WIRE_BUS 9// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
  9. OneWire oneWire(ONE_WIRE_BUS);
  10. // Pass our oneWire reference to Dallas Temperature.
  11. DallasTemperature sensors(&oneWire);
  12. void setup(void)
  13. {
  14. myservo.attach(5);
  15. // start serial port
  16. Serial.begin(9600);
  17. }
  18. void loop(void)
  19. {
  20. summe=0;
  21. int numberOfDevices; // Number of temperature devices found
  22. DeviceAddress tempDeviceAddress; // We'll use this variable to store a found device address
  23.  
  24. sensors.begin();
  25. // Grab a count of devices on the wire
  26. numberOfDevices = sensors.getDeviceCount();
  27. Serial.print("Parasit:");
  28. if (sensors.isParasitePowerMode()) Serial.print("ON ");
  29. else Serial.print("OFF ");
  30.  
  31. Serial.print(" Anzahl:");
  32. Serial.print(numberOfDevices, DEC);
  33. // report parasite power requirements
  34. sensors.requestTemperatures(); // Send the command to get temperatures
  35.  
  36. // Loop through each device, print out temperature data
  37. for(int i=0;i<numberOfDevices; i++)
  38. {
  39. // Search the wire for address
  40. if(sensors.getAddress(tempDeviceAddress, i))
  41. {
  42. // Output the device ID
  43. Serial.print(" Sensor");
  44. Serial.print(i+1,DEC);
  45. Serial.print(" =");
  46.  
  47. int tempC = sensors.getTempC(tempDeviceAddress);
  48. Serial.print(tempC);
  49. Serial.print(" Grad Celsius");
  50. {
  51.  
  52.  
  53. {
  54.  
  55. summe+=tempC;
  56. }
  57.  
  58.  
  59. Serial.print(summe);
  60.  
  61. }
  62.  
  63.  
  64.  
  65. val= tempC;
  66.  
  67. val= map(val, 28, 30, 0, 180);
  68. myservo.write(val);
  69. delay(15);
  70. }
  71.  
  72.  
  73. }
  74.  
  75. Serial.println("");
  76.  
  77. delay(1000);
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement