RamiChan

TempSensorCode

Apr 26th, 2016
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. //declare variables
  2. float tempC;
  3. int tempPin = 0;
  4.  
  5. void setup()
  6. {
  7. Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
  8. }
  9.  
  10. void loop()
  11. {
  12. tempC = analogRead(tempPin); //read the value from the sensor
  13. tempC = (5.0 * tempC * 100.0)/1024.0; //convert the analog data to temperature
  14. Serial.print((byte)tempC); //send the data to the computer
  15. delay(1000); //wait one second before sending new data
  16. }
Add Comment
Please, Sign In to add comment