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.

Revisions

  1. tristanm created this gist Feb 18, 2016.
    20 changes: 20 additions & 0 deletions digispark_temp_light.ino
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@

    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;
    }