|
各位大佬,问下这个代码怎么才能再esp8266上面运行,串口输出错误,哪位大佬有空帮忙看看怎么改
- #include <DS18B20.h>
- #include <TM1637Display.h>
- #define CLK 4
- #define DIO 5
- #define LOW_ALARM a
- #define HIGH_ALARM b
- TM1637Display display(CLK, DIO);
- DS18B20 ds(10);
- int a=20;
- int b=30;
- int c=0;
- int d=0;
- float t=0;
- int j=0;
- int k=0;
- void abc(){
- if((k==0)&&(j==1)){
- k=1;
- a++;
- }
- if((k==0)&&(j==2)){
- k=1;
- b++;
- }
- }
- void xyz(){
- if((k==0)&&(j==1)){
- k=1;
- a--;
- }
- if((k==0)&&(j==2)){
- k=1;
- b--;
- }
- }
- void setup() {
- Serial.begin(9600);
- attachInterrupt(0, abc, FALLING );
- attachInterrupt(1 ,xyz ,FALLING );
-
- pinMode(6,OUTPUT);
- digitalWrite(6,LOW);
- pinMode(7,INPUT);
- digitalWrite(7,HIGH);
- ds.setAlarms(LOW_ALARM, HIGH_ALARM);
- display.setBrightness(0x0f);
- }
- void loop() {
- if(digitalRead(7)==LOW)j++;
- if(j>2)j=0;
- t=ds.getTempC();
- if(t<a)digitalWrite(6,HIGH);
- if(t>b)digitalWrite(6,LOW);
-
- if(j==0)display.showNumberDecEx(t*100, (0x80 >> 1), false);
- if(j==1)display.showNumberDec(a, false);
- if(j==2){
- display.clear();
- display.showNumberDec(b,0,2,false);
- }
- k=0;
- }
复制代码
|
|