[英]Raspberry Pi Simple LED using python and GPIO not working
[英]Raspberry pi: Im using Some code for a Email alert with use of the GPIO ports for LED notifications
我正在使用Python RPi,並在網上找到一些編碼,通知我進來的電子郵件並點亮GPIO端口上的LED
這是代碼:
#!/usr/bin/env python
import RPi.GPIO as GPIO, feedparser, time
DEBUG = 1
USERNAME = ""
PASSWORD = ""
NEWMAIL_OFFSET = 1
MAIL_CHECK_FREQ = 60
GPIO.setmode(GPIO.BCM)
GREEN_LED = 18
RED_LED = 23
GPIO.setup (GREEN_LED, GPIO.OUT)
GPIO.setup(RED_LED, GPIO.OUT)
while True:
newmails = int(feedparser.parse("https://" + USERNAME + ":" + PASSWORD +"@mail.google.com/gmail/feed/atom")["feed"]["fullcount"])
if DEBUG:
print "You have" newmails, "new emails!"
if newmails > NEWMAIL_OFFSET:
GPIO.output (GREEN_LED, True)
GPIO.output (RED_LED, False)
else:
GPIO.output(GREEN_LED, False)
GPIO.output(RED_LED, True)
time.sleep(MAIL_CHECK_FREQ)
except KeyboardInterrupt:
GPIO.cleanup()
Python說“第一次打印是無效的。有人知道為什么嗎?
這是您機器上代碼的精確復制粘貼嗎? 看起來你在"You have"
和在新newmails
之前錯過了一個逗號。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.