Created
November 11, 2015 17:02
-
-
Save bzshang/67da28ad97b077b90d18 to your computer and use it in GitHub Desktop.
arduino-sketch-temperature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Bridge.h> | |
#include <Console.h> | |
const int temperaturePin = 0; | |
void setup() | |
{ | |
Bridge.begin(); | |
Console.begin(); | |
while (!Console){ | |
; // wait for Console port to connect. | |
} | |
Console.println("You're connected to the Console!!!!"); | |
} | |
void loop() | |
{ | |
float voltage, degreesC, degreesF; | |
voltage = getVoltage(temperaturePin); | |
degreesC = (voltage - 0.5) * 100.0; | |
degreesF = degreesC * (9.0/5.0) + 32.0; | |
Console.print("voltage: "); | |
Console.print(voltage); | |
Console.print(" deg C: "); | |
Console.print(degreesC); | |
Console.print(" deg F: "); | |
Console.println(degreesF); | |
Bridge.put("TEMP", String(degreesF)); | |
delay(5000); // repeat once per 5 seconds (change as you wish!) | |
} | |
float getVoltage(int pin) | |
{ | |
return (analogRead(pin) * 0.004882814); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment