In my project I invoke a python script via node.js on my Rapberrypi B+ model and what the python script does is that it turns on the BCM GPIO ports as per the python arguments passed through the node.js
$>python my_gpio.py 27 1
where 27 is the pin no and 1 is the on/off state
#my_gpio.py code
import sys
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
f= open("GPIO","a+")
pin = sys.argv[1]
gpin = int(sys.argv[1])
state = sys.argv[2]
GPIO.setup(gpin, GPIO.OUT)
if state == "1" :
f.write("\nPIN " +pin + " is on "+ state )
GPIO.output(gpin, GPIO.HIGH)
else:
f.write("\nPIN " +pin + " is off "+ state)
GPIO.output(gpin, GPIO.LOW)
f.close
print("Done")
sys.stdout.flush()
What my objective is that I want to keep my LED HIGH until next event from the node to turn it off or turn it on
- Should I be worried of not using GPIO.cleanup()? If i use GPIO.cleanup it will turn of the LED right?
- Will there be any issue if I execute the above code like this,
$>python my_gpio.py 27 1
$>python my_gpio.py 27 1
ie, calling GPIO.output(gpin, GPIO.HIGH) on a GPIO.HIGH - What are the risk i should avoid, so that i wont fry my board?