#include <LedControl.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 11
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
float Tfloat;
long Tint;
LedControl lc=LedControl(8,10,9,1);
// Pin 8->DIN, 10->CLK, 9->CS(LOAD), 1 = No.of devices
void show6digit(int num)
{
int seg1,seg2;
seg2 = (((((num%100000)%10000)%1000)%100)/10);
seg1 = (((((num%100000)%10000)%1000)%100)%10);
lc.setDigit(0,0,seg1,false);
if (num>=10)
lc.setDigit(0,1,seg2,false);
delay(300);
}
void setup(void)
{
sensors.begin();
lc.shutdown(0,false);
lc.setIntensity(0,5);
lc.clearDisplay(0);
}
void loop(void)
{
sensors.requestTemperatures();
Tfloat = sensors.getTempCByIndex(0);
Tint = int(Tfloat);
lc.clearDisplay(0);
show6digit(Tint);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น