Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <OneWire.h>
- #include <DallasTemperature.h>
- #include <Servo.h>
- Servo myservo;
- int val;
- int summe;
- // Data wire is plugged into port 2 on the Arduino
- #define ONE_WIRE_BUS 9// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
- OneWire oneWire(ONE_WIRE_BUS);
- // Pass our oneWire reference to Dallas Temperature.
- DallasTemperature sensors(&oneWire);
- void setup(void)
- {
- myservo.attach(5);
- // start serial port
- Serial.begin(9600);
- }
- void loop(void)
- {
- summe=0;
- int numberOfDevices; // Number of temperature devices found
- DeviceAddress tempDeviceAddress; // We'll use this variable to store a found device address
- sensors.begin();
- // Grab a count of devices on the wire
- numberOfDevices = sensors.getDeviceCount();
- Serial.print("Parasit:");
- if (sensors.isParasitePowerMode()) Serial.print("ON ");
- else Serial.print("OFF ");
- Serial.print(" Anzahl:");
- Serial.print(numberOfDevices, DEC);
- // report parasite power requirements
- sensors.requestTemperatures(); // Send the command to get temperatures
- // Loop through each device, print out temperature data
- for(int i=0;i<numberOfDevices; i++)
- {
- // Search the wire for address
- if(sensors.getAddress(tempDeviceAddress, i))
- {
- // Output the device ID
- Serial.print(" Sensor");
- Serial.print(i+1,DEC);
- Serial.print(" =");
- int tempC = sensors.getTempC(tempDeviceAddress);
- Serial.print(tempC);
- Serial.print(" Grad Celsius");
- {
- {
- summe+=tempC;
- }
- Serial.print(summe);
- }
- val= tempC;
- val= map(val, 28, 30, 0, 180);
- myservo.write(val);
- delay(15);
- }
- }
- Serial.println("");
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement