This commit is contained in:
commit
523e43c3f1
1 changed files with 46 additions and 0 deletions
46
TC74readout
Normal file
46
TC74readout
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#include <Wire.h>
|
||||
//wire library
|
||||
|
||||
/*
|
||||
Sourced from
|
||||
http://www.instructables.com/id/Thermostat-Microcontroller-with-an-Arduino-and-a-T/step4/TC74-Arduino-code/
|
||||
and modified a bit!
|
||||
*/
|
||||
|
||||
//works better when you connect SDA and SCLK
|
||||
|
||||
#define address B1001101
|
||||
#define baudrate 9600
|
||||
//baudrate for communication
|
||||
|
||||
byte val = 0;
|
||||
void setup()
|
||||
{
|
||||
Wire.begin();
|
||||
Serial.begin(baudrate);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.print("temperature in Celsius: ");
|
||||
//let's signal we're about to do something
|
||||
|
||||
int temperature;
|
||||
//temperature in a byte
|
||||
|
||||
Wire.beginTransmission(address);
|
||||
//start the transmission
|
||||
|
||||
Wire.write(val);
|
||||
|
||||
Wire.requestFrom(address, 1);
|
||||
if (Wire.available()) {
|
||||
temperature = Wire.read();
|
||||
Serial.println(temperature);
|
||||
}
|
||||
|
||||
else {
|
||||
Serial.println("---");
|
||||
}
|
||||
delay(5000);
|
||||
}
|
||||
Loading…
Reference in a new issue