Skip to content

Instantly share code, notes, and snippets.

@SharkyRawr
Created September 4, 2019 17:50
Show Gist options
  • Save SharkyRawr/f9b3f8b073851d2286699d71be3d5c89 to your computer and use it in GitHub Desktop.
Save SharkyRawr/f9b3f8b073851d2286699d71be3d5c89 to your computer and use it in GitHub Desktop.
#include <DigiCDC.h>
// the setup routine runs once when you press reset:
void setup() {
SerialUSB.begin();
// initialize the digital pin as an output.
pinMode(1, OUTPUT); //LED on Model A
}
int get_temp() {
analogReference(INTERNAL1V1);
int raw = analogRead(A0+15);
/* Original code used a 13 deg adjustment. But based on my results, I didn't seem to need it. */
// raw -= 13; // raw adjust = kelvin //this value is used to calibrate to your chip
int in_c = raw - 273; // celcius
analogReference(DEFAULT);
return in_c;
}
char msg[128];
// the loop routine runs over and over again forever:
void loop() {
// turn the LED on (HIGH is the voltage level)
digitalWrite(1, HIGH);
SerialUSB.delay(500);
//delay(1000); // wait for a second
// turn the LED off by making the voltage LOW
digitalWrite(1, LOW);
//delay(1000); // wait for a second
SerialUSB.delay(500);
sprintf(msg, "temp: %d\r\n", get_temp());
SerialUSB.print(msg);
SerialUSB.refresh();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment