#include <DHT.h>
#include <Servo.h>
#define DHTPIN 6 //defines what pin the temp sensor is connected to.
#define DHTTYPE DHT22//defines type of temprature sensor.
DHT dht(DHTPIN, DHTTYPE); //start up/turn on DHT sensor.
float temp; //temp value storage.
Servo servo; //creates servo body.
//set up section for assigning arduino board values and starting components
void setup() {
Serial.begin(9600); //starts communication at 9600 baud rate(avg).
dht.begin();//start up DHT sensor.
servo.attach(5); //servo motor attached to pin 5.
}
//actual code that we want the system to undertake.
void loop()
{
float temperature = dht. readTemperature();// reads temprature of DHT22 sensor and assigns it to "temprature".
int servoAngle = map(temperature,-40, 80, 0, 180);// relates tempratures -40 and 80 to degrees 0 and 180.
servo.write(servoAngle);// moves servo motor to angle from temprature reading.
}