Skip to content

Instantly share code, notes, and snippets.

@tristanm
Created February 18, 2016 05:25
Show Gist options
  • Save tristanm/5c943ec640556cf36a5c to your computer and use it in GitHub Desktop.
Save tristanm/5c943ec640556cf36a5c to your computer and use it in GitHub Desktop.
Digispark Temp Light
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