I'm trying to get a iPhone app to control GPIO pins over WiFi.
So far I've written an app for the iPhone that has buttons which call a URL.
example of what the App buttons do:
Code: Select all
example.com/pi/setid.php?id=1Once that URL is called, it updates a value in a MYSQL Database.
I also have another webpage that just echos the value. I have a python script that reads that value and then sets specific GPIO pins depending on what the value is.
Over all, it works fine and the value is past across it all. However, sometimes it takes quite a while for the pi to react to the value. I thought it might have just been connection speeds or something. I deceived to check how quickly the python script can get the value. I edited the script and got it to print the value to the screen.
The value that's printed responds instantly with the updated value, however there is still a delay for when the motor responds.
python script:
Code: Select all
import RPi.GPIO as gpio
import time
import urllib2
gpio.setmode(gpio.BOARD)
gpio.setup(7, gpio.OUT)
gpio.setup(11, gpio.OUT)
gpio.setup(13, gpio.OUT)
gpio.setup(15, gpio.OUT)
gpio.output(7, True)
gpio.output(11, True)
while 1:
page = urllib2.urlopen('http://example.com/pi/request.php')
x = page.read()
print(x)
if x == "1":
gpio.output(13, False)
gpio.output(15, True)
elif x == "2":
gpio.output(15, False)
gpio.output(13, True)
else:
gpio.output(15, False)
gpio.output(13, False)

What am I doing wrong?
I have ruled out it being the motors fault by making a script that makes it go forwards for 2 seconds and then backwards. It works fine. Just not when I add in this bit.