These are chat archives for nebrius/raspi-io

25th
Oct 2016
iotkid
@iotkid
Oct 25 2016 21:35
Hello, Good evening! I have a quick question about Raspberry Pi GPIO. I have a python program that I want it to turns on and off a relay module connected to my Raspberry Pi. I am able to turn ON and OFF, but I can't do it in a single python program. I was wondering if anyone else had similar situation. Please help me, it is driving me nuts :smile:
code is very simple - Here is what I have -

LED = 4

GPIO.setmode(GPIO.BCM)
GPIO.setup(LED, GPIO.OUT)
GPIO.output(LED, GPIO.HIGH)
GPIO.output(LED, GPIO.LOW)
GPIO.cleanup()

```LED = 4

GPIO.setmode(GPIO.BCM)
GPIO.setup(LED, GPIO.OUT)
GPIO.output(LED, GPIO.HIGH)
GPIO.output(LED, GPIO.LOW)
GPIO.cleanup()
```

Bryan Hughes
@nebrius
Oct 25 2016 22:10
In your code, you turn it on and off very fast, basically instantaneously, so the relay never has a chance to change. You’ll need to tell your program to wait a bit after turning it high before turning it low. I have no idea how to do that in Python though, this Gitter channel is specifically for working with the Raspberry Pi from JavaScript.
@iotkid ^^
iotkid
@iotkid
Oct 25 2016 22:11
@nebrius - Thank you! Even if I had sleep between GPIO.output, the result is the same.
Bryan Hughes
@nebrius
Oct 25 2016 22:12
no idea then, probably something Python specific
iotkid
@iotkid
Oct 25 2016 22:12
thank you for your help... will look into the python documentation
Bryan Hughes
@nebrius
Oct 25 2016 22:13
best of luck!
iotkid
@iotkid
Oct 25 2016 22:35
@nebrius Thanks! Since you mentioned this thread is for Raspberry Pi and Javascript, are there any good js libraries available for managing GPIOs visually?
Luis Montes
@monteslu
Oct 25 2016 22:36
@iotkid node-red-contrib-gpio lets you draw connections :)
iotkid
@iotkid
Oct 25 2016 22:37
thank you... will take a look...
Luis Montes
@monteslu
Oct 25 2016 22:38
its node-red + raspi-io + johnny-five