本次目标手工做一个恋爱日计数器
一、技术路线
Micropython + esp8266 + OLED (7针脚 SPI接口) + 四根杜邦线(母对母)
二、开干
1、esp8266固件烧写,参考下面链接小明同学:Micropythonzhuanlan.zhihu.com
2、esp8266和OLED针角连接
3、下载SSD1306
使用SSD1306驱动将Micropython输出的数据转换为OLED屏幕上对应的发光点显示出来。下载ssd1306.py文件拷贝至esp8266目录中。https://github.com/micropython/micropython/tree/master/drivers/displaygithub.com
4、点亮屏幕
from machine import Pin,SPI
import ssd1306
hspi = SPI(1,baudrate=80000000,polarity=0,phase=0)
display = ssd1306.SSD1306_SPI(128,64,hspi,Pin(5),Pin(4),Pin(16))
display.init_display()
display.text('Hello,World',1,1)
5、显示纪念天数
from machine import Pin,SPI
import ssd1306
import time
hspi = SPI(1,baudrate=80000000,polarity=0,phase=0)
display = ssd1306.SSD1306_SPI(128,64,hspi,Pin(5),Pin(4),Pin(16))
display.init_display()
starttime = str(425)
while 1:
display.text('KKming And Tay',10,1)
display.show()
display.text('Love Memorial',10,51)
display.show()
#显示纪念天数
display.text(starttime + ' Days',35,25)
display.show()
#等待3S,为了显示效果
time.sleep(3)
#清空屏幕
display.fill(0)
#更改时间
starttime = int(starttime)
starttime += 1
starttime = str(starttime)
6、制作手工外壳