Digispark LM61CIZ Temperature Sensor
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 <DigiUSB.h> | |
void setup() | |
{ | |
pinMode(2, INPUT); // P2 = anolog input 1 | |
pinMode(1, OUTPUT); | |
DigiUSB.begin(); | |
} | |
void loop() | |
{ | |
digitalWrite(1, HIGH); | |
int step; | |
float temp; | |
step = analogRead(1); | |
temp = (float)step*500.0/1024.0-60.0; | |
DigiUSB.print("{\"temp\":"); | |
DigiUSB.print(temp); | |
DigiUSB.println("}"); | |
digitalWrite(1, LOW); | |
DigiUSB.delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
blog http://atotto.hatenadiary.jp/entry/digispark_lm61_usb (lang=ja)