Created
February 18, 2016 05:25
-
-
Save tristanm/5c943ec640556cf36a5c to your computer and use it in GitHub Desktop.
Digispark Temp Light
This file contains hidden or 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
void setup() { | |
pinMode(1, OUTPUT); | |
} | |
void loop() { | |
if (getTemp() > 30) { | |
digitalWrite(1, HIGH); | |
} else { | |
digitalWrite(1, LOW); | |
} | |
} | |
int getTemp() { | |
analogReference(INTERNAL1V1); | |
int raw = analogRead(A0 + 15); | |
int celcius = raw - 273; | |
analogReference(DEFAULT); | |
return celcius; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment