Created
February 9, 2012 12:09
-
-
Save davedarko/1779562 to your computer and use it in GitHub Desktop.
Arduino LM75
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
// based on http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1290115931 | |
#include <Wire.h> | |
int t,l; | |
void setup() { | |
Wire.begin(); | |
Serial.begin(9600); | |
} | |
void loop() { | |
Wire.send(0x00); | |
Wire.requestFrom(B1001111, 2); | |
while(Wire.available()) { | |
int8_t msb = Wire.receive(); | |
int8_t lsb = Wire.receive(); | |
// strip one bit of the lsb | |
lsb = (lsb & 0x80 ) >> 7; // now lsb = 0 or 1 | |
// add to to form an float | |
float f = msb + 0.5 * lsb; | |
Serial.println(f,1); | |
} | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment