Amine BENDAHMANE
PhD student on AI & Robotics
import RPi.GPIO as GPIO
import urllib2
# init
lamp = 40
GPIO.setmode(GPIO.BOARD)
GPIO.setup(lamp, GPIO.OUT)
while True:
# get the lamp status from the server
status = urllib2.urlopen("http://udevcommunity.org/
uconf2-iot-test/get_lamp_status.php").read()
# Turn ligh ON/OFF according to the server response
if (status == '1') # ON
GPIO.output(lamp, 1)
elif (status == '0') # OFF
GPIO.output(lamp, 0)
<?php
$status = file_get_contents('lamp_status.txt');
print intval($status);
?>
<?php
if ($buttonState == 0)
file_put_contents('lamp_status.txt', '1');
else file_put_contents('lamp_status.txt', '0');
?>
bendahmane.amine@gmail.com
AmineHorseman