#include "Wire.h"
#define SENSOR_ADDRESS 0x68
#define TEMP_INT_POINTER 0x11
#define TEMP_DEC_POINTER 0x12
#define TEMP_READ_FAIL 0xFF
#define LATCH_DIO 4
#define CLK_DIO 7
#define DATA_DIO 8
const byte leterE = B10000110;
const byte num0 = B11000000;
const byte num1 = B11111001;
const byte num2 = B10100100;
const byte num3 = B10110000;
const byte num4 = B10011001;
const byte num5 = B10010010;
const byte num6 = B10000010;
const byte num7 = B11111000;
const byte num8 = B10000000;
const byte num9 = B10010000;
const byte nums[]= {num0,num1,num2,num3,num4,num5,num6,num7,num8,num9};
const byte point1 = B00000001;
const byte point2 = B00000010;
const byte point3 = B00000100;
const byte dot = B01111111;
void setup()
{
pinMode(LATCH_DIO,OUTPUT);
pinMode(CLK_DIO,OUTPUT);
pinMode(DATA_DIO,OUTPUT);
Wire.begin();
Serial.begin(9600);
}
void loop()
{
displayTemperature();
}
void displayTemperature()
{ byte data = TEMP_READ_FAIL;
Wire.beginTransmission(SENSOR_ADDRESS);
Wire.write(TEMP_INT_POINTER); // the integer portion
Wire.endTransmission();
Wire.requestFrom(SENSOR_ADDRESS, 1);
if (Wire.available()) {
data = Wire.read();
displayNow(nums[data%10],point2);
data=data-data%10;
displayNow(nums[(data%100)/10],point1);
}
else{
displayNow(dot, point3);
}
}
void displayNow(byte x, byte y){
digitalWrite(LATCH_DIO,LOW);
shiftOut(DATA_DIO, CLK_DIO, MSBFIRST, x);
shiftOut(DATA_DIO, CLK_DIO, MSBFIRST, y );
digitalWrite(LATCH_DIO,HIGH);
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}