51单片机ds18b20用oled显示程序
时间: 2023-10-15 21:02:46 浏览: 92
以下是51单片机使用ds18b20和OLED显示温度的程序:
```c
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define DS DSPORT //DS18B20数据线
#define DSPORT P1_4 //DS18B20数据线接口
sbit SCL=P2^1; //OLED时钟线
sbit SDA=P2^0; //OLED数据线
uchar code c[]={ //OLED码表
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
uchar code font[]={ //OLED字体库
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //空格
0x00,0x00,0x00,0x00,0x4f,0x00,0x00,0x00, //!
0x00,0x00,0x00,0x07,0x00,0x07,0x00,0x00, //"
0x00,0x00,0x14,0x7f,0x14,0x7f,0x14,0x00, //#
0x00,0x00,0x24,0x2a,0x7f,0x2a,0x12,0x00, //$
0x00,0x00,0x23,0x13,0x08,0x64,0x62,0x00, //%
0x00,0x00,0x36,0x49,0x55,0x22,0x50,0x00, //&
0x00,0x00,0x00,0x05,0x03,0x00,0x00,0x00, //'
0x00,0x00,0x00,0x1c,0x22,0x41,0x00,0x00, //(
0x00,0x00,0x00,0x41,0x22,0x1c,0x00,0x00, //)
0x00,0x00,0x14,0x08,0x3e,0x08,0x14,0x00, //*
0x00,0x00,0x08,0x08,0x3e,0x08,0x08,0x00, //+
0x00,0x00,0x00,0x50,0x30,0x00,0x00,0x00, //,
0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x00, //-
0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00, //.
0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x00, ///
0x00,0x00,0x3e,0x51,0x49,0x45,0x3e,0x00, //0
0x00,0x00,0x00,0x42,0x7f,0x40,0x00,0x00, //1
0x00,0x00,0x42,0x61,0x51,0x49,0x46,0x00, //2
0x00,0x00,0x21,0x41,0x45,0x4b,0x31,0x00, //3
0x00,0x00,0x18,0x14,0x12,0x7f,0x10,0x00, //4
0x00,0x00,0x27,0x45,0x45,0x45,0x39,0x00, //5
0x00,0x00,0x3c,0x4a,0x49,0x49,0x30,0x00, //6
0x00,0x00,0x01,0x71,0x09,0x05,0x03,0x00, //7
0x00,0x00,0x36,0x49,0x49,0x49,0x36,0x00, //8
0x00,0x00,0x06,0x49,0x49,0x29,0x1e,0x00, //9
0x00,0x00, 0x00,0x36,0x36,0x00,0x00,0x00, //:
0x00,0x00,0x00,0x56,0x36,0x00,0x00,0x00, //;
0x00,0x00,0x08,0x14,0x22,0x41,0x00,0x00, //<
0x00,0x00,0x14,0x14,0x14,0x14,0x14,0x00, //=
0x00,0x00,0x00,0x41,0x22,0x14,0x08,0x00, //>
0x00,0x00,0x02,0x01,0x51,0x09,0x06,0x00, //?
0x00,0x00,0x32,0x49,0x79,0x41,0x3e,0x00, //@
0x00,0x00,0x7e,0x11,0x11,0x11,0x7e,0x00, //A
0x00,0x00,0x7f,0x49,0x49,0x49,0x36,0x00, //B
0x00,0x00,0x3e,0x41,0x41,0x41,0x22,0x00, //C
0x00,0x00,0x7f,0x41,0x41,0x22,0x1c,0x00, //D
0x00,0x00,0x7f,0x49,0x49,0x49,0x41,0x00, //E
0x00,0x00,0x7f,0x09,0x09,0x09,0x01,0x00, //F
0x00,0x00,0x3e,0x41,0x49,0x49,0x7a,0x00, //G
0x00,0x00,0x7f,0x08,0x08,0x08,0x7f,0x00, //H
0x00,0x00,0x00,0x41,0x7f,0x41,0x00,0x00, //I
0x00,0x00,0x20,0x40,0x41,0x3f,0x01,0x00, //J
0x00,0x00,0x7f,0x08,0x14,0x22,0x41,0x00, //K
0x00,0x00,0x7f,0x40,0x40,0x40,0x40,0x00, //L
0x00,0x00,0x7f,0x02,0x04,0x02,0x7f,0x00, //M
0x00,0x00,0x7f,0x04,0x08,0x10,0x7f,0x00, //N
0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00, //O
0x00,0x00,0x7f,0x09,0x09,0x09,0x06,0x00, //P
0x00,0x00,0x3e,0x41,0x51,0x21,0x5e,0x00, //Q
0x00,0x00,0x7f,0x09,0x19,0x29,0x46,0x00, //R
0x00,0x00,0x46,0x49,0x49,0x49,0x31,0x00, //S
0x
阅读全文