Skip to content

Instantly share code, notes, and snippets.

@pandyma
Created April 11, 2018 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandyma/314987e641af3c7d3909685ba8e21b77 to your computer and use it in GitHub Desktop.
Save pandyma/314987e641af3c7d3909685ba8e21b77 to your computer and use it in GitHub Desktop.
#include <Servo.h>
float temp;
int tempPin = 0;
int cold = 55;
int hot = 55.5;
int servocold = 100;
int servohot = 10;
Servo servol;
void setup() {
Serial.begin(9600);
servol.attach(9);
}
void loop() {
temp = analogRead(tempPin); //read temp sensor
temp = temp * 0.48828125;
Serial.print("TEMPRTATURE = ");
Serial.print(temp);
Serial.print("*C");
Serial.println();
if(temp < cold){//if temp below cold(20),do this
servol.write(servocold);
} else if (temp > hot) {
servol.write(servohot);
}
delay(3000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment