The 230V 1 is currently on (turn off)
The 230V 2 is currently on (turn off)
The blue lamp is currently off (turn on)
The red lamp is currently on (turn off)
{% for pin in pins %}
<li>
<p>The {{ pins[pin].name }}
{% if pins[pin].state == true %}
is currently on (<a href="/RaspberryPi/LampControl.html//off">turn off</a>)
{% else %}
is currently off (<a href="/RaspberryPi/LampControl.html//on">turn off</a>)
{% endif %}
</p>
</li>
{% endfor %}
self.pins = {
24 : {'name' : 'blue lamp', 'state' : GPIO.LOW},
25 : {'name' : 'red lamp', 'state' : GPIO.LOW}
}
for pin in self.pins:
GPIO.setup(pin, GPIO.OUT)
self.pins[pin]['state'] = GPIO.input(pin)
def setPin(self,changePin,action):
GPIO.setmode(GPIO.BCM)
GPIO.setup(changePin, GPIO.OUT)
if action == "on":
GPIO.output(changePin, GPIO.HIGH)
if action == "off":
GPIO.output(changePin, GPIO.LOW)
if action == "toggle":
# Read the pin and set it to whatever it isn't (that is, toggle it):
GPIO.output(changePin, not GPIO.input(changePin))