Hello all,
I am a 100% newbie.
I am looking to use a simple control to trigger an action. I have some code used for GPIO, however I would like to connect to my relay using the USB port instead of the pins. can someone please help to modify the code to talk to the USB port, instead of using the pins.
Is there an easy way tell the Pi, to do the GPIO operation using the USB?
THANKS,
here is the current code:
import web, requests
import RPi.GPIO as GPIO
import time
urls = ('/advance/(.*)/(.*)', 'advance')
app = web.application(urls, globals())
class advance:
def GET(self, digi_cam_ip, loops):
for loop in range(0, int(loops)):
# specify how the pins are referred to
GPIO.setmode(GPIO.BOARD)
# pin the relay is connected to on the Raspberry Pi
pin = 2
# activate the relay for 0.25 seconds, then release
GPIO.setup(pin, GPIO.OUT)
GPIO.output(pin, GPIO.LOW)
time.sleep(0.25)
GPIO.output(pin, GPIO.HIGH)
GPIO.cleanup()
# wait for the projector to advance the slide
time.sleep(0.5)
# take the picture by calling DigiCam's webservice
requests.post("http://" + digi_cam_ip + ":5513/?CMD=Capture")
# wait for the image to transfer from the camera to the computer
time.sleep(2)
return "Finished"
if _name_ == "__main__":
app.run()