Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*-----------------------------------------------
- * Arduino Analog-ish Thermometer
- * www.youtube.com/learnelectronics
- * email: arduino0169@gmail.com
- * 12/26/2020
- * You are free to use my code however you
- * want as long as you give me credit.
- ------------------------------------------------*/
- #include "DHT.h"
- #include <Servo.h>
- #define DHTPIN 8
- #define DHTTYPE DHT11
- DHT dht(DHTPIN, DHTTYPE);
- Servo myservo;
- int potpin = 0;
- int val;
- int Tred = 0;
- void setup() {
- myservo.attach(9); // attaches the servo on pin 9 to the servo object
- Serial.begin(9600);
- Serial.println(F("DHTxx test!"));
- dht.begin();
- }
- void loop(){
- float f = dht.readTemperature(true);
- val = (int)f;
- Tred = map(val,-20,120,0,180);
- Serial.println(f);
- Serial.println(val);
- Serial.println(Tred);
- myservo.write(val);
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement