Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. int sensePin = A0; //This is the Arduino Pin that will control Relay #1
  2. int sensorInput; //The variable we will use to store the sensor input
  3. double temp; //The variable we will use to store temperature in degrees.
  4.  
  5. void setup() {
  6. // put your setup code here, to run once:
  7. Serial.begin(9600); //Start the Serial Port at 9600 baud (default)
  8.  
  9. }
  10. void loop() {
  11. // put your main code here, to run repeatedly:
  12. sensorInput = analogRead(A0); //read the analog sensor and store it
  13. temp = (double)sensorInput / 1024; //find percentage of input reading
  14. temp = temp * 5; //multiply by 5V to get voltage
  15. temp = temp - 0.5; //Subtract the offset
  16. temp = temp * 100; //Convert to degrees
  17.  
  18. Serial.print("Current Temperature: ");
  19. Serial.println(temp);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement