#include <Servo.h> // defines what studios we will use
#include <DHT.h>
#define DHTPIN 7 // tells code what pio the thermometer is connected too
#define DHTTYPE DHT22 // defien what thermometer is being used
DHT dht (DHTPIN, DHTTYPE);
Servo servo;
void setup()
{
servo.attach(5); // tells code which pin is connected
Serial.begin(9600); // baud rate
dht.begin(); // starts the code
pinMode(13,OUTPUT); // tells code what pin is a output
}
void loop(){ // start the loop
float temp = dht.readTemperature(); // takes the reading from the thermometer and stores it as a float with the name vairable temp
int angle = map(temp, -40, 80, 0, 180) ; // tells thermometer what values its reading
angle = constrain(angle, 0, 180); // makes sure the motor does not go over theres angles
servo.write(angle);
temp = dht.readTemperature(); // prints angle and temp
Serial.print("Temp = ");
Serial.print(temp);
Serial.println("Celius");
delay(1000);
}