raspberry pi led

web控制led

视频链接

代码(非常简单):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import web
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
urls = (
'/(.*)', 'hello'
)
app = web.application(urls, globals())
class hello:
def GET(self, name):
if name == 'on':
name = 'test'
GPIO.output(18,GPIO.HIGH)
if name == 'off':
GPIO.output(18,GPIO.LOW)
if not name:
name = 'World'
return 'Hello, ' + name + '!'
if __name__ == "__main__":
app.run()