Yet Another WebIOPi+
 All Classes Namespaces Files Functions Variables Macros Pages
script.py
Go to the documentation of this file.
1 # Imports
2 import webiopi
3 
4 # Enable debug output
5 webiopi.setDebug()
6 
7 # Retrieve GPIO lib
8 GPIO = webiopi.GPIO
9 SWITCH = 21
10 SERVO = 23
11 LED0 = 24
12 LED1 = 25
13 
14 # Called by WebIOPi at script loading
15 def setup():
16  webiopi.debug("Basic script - Setup")
17  # Setup GPIOs
18  GPIO.setFunction(SWITCH, GPIO.IN)
19  GPIO.setFunction(SERVO, GPIO.PWM)
20  GPIO.setFunction(LED0, GPIO.PWM)
21  GPIO.setFunction(LED1, GPIO.OUT)
22 
23  GPIO.pwmWrite(LED0, 0.5) # set to 50% ratio
24  GPIO.pwmWriteAngle(SERVO, 0) # set to 0 (neutral)
25  GPIO.digitalWrite(LED1, GPIO.HIGH)
26 
27 # Called by WebIOPi at server shutdown
28 def destroy():
29  webiopi.debug("Basic script - Destroy")
30  # Reset GPIO functions
31  GPIO.setFunction(SWITCH, GPIO.IN)
32  GPIO.setFunction(SERVO, GPIO.IN)
33  GPIO.setFunction(LED0, GPIO.IN)
34  GPIO.setFunction(LED1, GPIO.IN)
def destroy
Definition: script.py:28
def setup
Definition: script.py:15