2374 views|1 replies

156

Posts

1

Resources
The OP
 

【pyboardCN V2】Driving OLED and DHT11 [Copy link]

  I modified the OLED and DHT11 routines of other pyb masters, which is really helpful for beginners like me who don’t have a deep foundation in MicroPython. The code is as follows: 程序代码.zip (3 KB, downloads: 11) from pyb import LED #add LED import DHTsensor import ssd1306 import machine import time from machine import Pin from machine import I2C from machine import SPI # construct an SPI bus on the given pins # polarity is the idle state of SCK # phase=0 means sample on the first edge of SCK, phase=1 means the second # OLED #Pin(14)--SC K machine.Pin("B13") --D0 #Pin(13)--MOSI machine.Pin("B15") --D1 #Pin(12)--MISO machine.Pin("B14") //Not used #Pin(16)--CS machine.Pin("B0 ") --CS #Pin(4)--RES machine.Pin("B10") --RES #Pin(5)--DC machine.Pin("B11") --DC spi=SPI( baudrate=10000000, polarity=1, phase=0, sck=machine.Pin("B13"), mosi=machine.Pin("B15"), miso=machine.Pin("B14")) display=ssd1306.SSD1306_SPI( 128, 64, spi , machine.Pin("B11"), machine.Pin("B10"), machine.Pin("B0")) led_blue = LED(4) led_blue.on() dht = DHTsensor.DHT11(Pin("B12")) #try: display.poweron() display.init_display() display.text("pyb dht11",1,1) display.text("donatello1996" ,1,16) display.text("temp:",1,32) display.text("humi:",1,48) display.show() while True: dht.measure() display.text(str(dht.temperature()),40,32) display.text(str(dht.humidity()),40,48) display.show()


Latest reply

Good, keep up the good work. I will try MicroPython when I have time. I will ask you for advice when I have time^_^  Details Published on 2018-9-10 08:37

赞赏

1

查看全部赞赏

 
 

1368

Posts

6

Resources
2
 
Good, keep up the good work. I will try MicroPython when I have time. I will ask you for advice when I have time^_^
Personal signature专注智能产品的研究与开发,专注于电子电路的生产与制造……QQ:2912615383,电子爱好者群: void
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list