Page 1 of 1

RevPi DIO - Manage Input Pin in Python Script

Posted: 23 Dec 2019, 17:42
by sixwac
Hi,
i'm a new user on the RevPI Forum.
I buy the RevPi Core and RevPi DIO.

I should turn on a Led when a button is pressed.
In python on Raspberry Pi 3b+ my code was the

#SETUP PIN
GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(8, GPIO.OUT, GPIO.LOW)

#INIT VARIABLE
bool ON_OFF=False

#DEFINE FUNCTION
def ButtonPressed(channel):
if GPIO.input(7)==1:
ON_OFF=True

def ButtonReleased(channel):
if GPIO.input(7)==0:
ON_OFF=False

#DEFINE INTERRUPT EVENT
GPIO.add_event_detect(7, GPIO.RISING, callback=ButtonPressed, bouncetime=300)
GPIO.add_event_detect(7, GPIO.FALLING, callback=ButtonReleased, bouncetime=300)

#WHILE TRUE CODE
while True:
if(ON_OFF)==True:
GPIO.output(8, HIGH)

How is possible to replicate this in Revolution Pi?
How can is possible to manage Input status from python in Revolution Pi?

Thanks in advance.
Emiliano

Re: RevPi DIO - Manage Input Pin in Python Script

Posted: 07 Jan 2020, 11:42
by dirk
Hi have a look at this snippet here:
viewtopic.php?f=6&t=1626&p=6250&hilit=mirror#p6250