Skip to content

Instantly share code, notes, and snippets.

@davedarko
Created February 9, 2012 12:09
Show Gist options
  • Save davedarko/1779562 to your computer and use it in GitHub Desktop.
Save davedarko/1779562 to your computer and use it in GitHub Desktop.
Arduino LM75
// 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