ESP8266+OLED(时间跳动)
1 #include <Arduino.h>
2 #include <U8g2lib.h>
3 #include <Wire.h>
4
5 //iic驱动方式
6 U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);
7
8 void setup(void) {
9 u8g2.begin();
10 }
11
12 uint8_t m = 24;
13
14 void loop(void) {
15 char m_str[3];
16 strcpy(m_str, u8x8_u8toa(m, 2)); /* convert m to a string with two digits */
17 u8g2.firstPage();
18 do {
19 u8g2.setFont(u8g2_font_logisoso62_tn);
20 u8g2.drawStr(0,63,"9");
21 u8g2.drawStr(33,63,":");
22 u8g2.drawStr(50,63,m_str);
23 } while ( u8g2.nextPage() );
24 delay(1000);
25 m++;
26 if ( m == 60 )
27 m = 0;
28 }
关注公众号:Python爬虫数据分析挖掘,学习更多python知识
耐得住寂寞,才能登得顶
Gitee码云:https://gitee.com/lyc96/projects