瀏覽單個文章
darkangel
Major Member
 
darkangel的大頭照
 

加入日期: Aug 2001
文章: 211
把 read 那行移到 while 迴圈裡試試如下。

代碼:
import RPi.GPIO as GPIO
import Adafruit_DHT
import I2C_LCD_driver
import time

mylcd = I2C_LCD_driver.lcd()
DHT_TYPE = Adafruit_DHT.DHT22
DHT_PIN  = 4

while True:
    mylcd.lcd_display_string("Time: %s" %time.strftime("%H:%M:%S"), 1)
    mylcd.lcd_display_string("Date: %s" %time.strftime("%m/%d/%Y"), 2)
    humidity, temp = Adafruit_DHT.read(DHT_TYPE, DHT_PIN)
    mylcd.lcd_display_string("Humidity:    %d %%" % humidity, 4)
    mylcd.lcd_display_string("temperature: %d C" % temp, 3)
 
__________________
滿招損 謙受益
舊 2017-02-19, 12:14 AM #2
回應時引用此文章
darkangel離線中