RevPi DIO - Manage Input Pin in Python Script

Show the world your Revolution Pi project!
Post Reply
sixwac
Posts: 2
Joined: 23 Dec 2019, 14:50
Answers: 0

RevPi DIO - Manage Input Pin in Python Script

Post 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
User avatar
dirk
KUNBUS
Posts: 1939
Joined: 15 Dec 2016, 13:19
Answers: 4

Re: RevPi DIO - Manage Input Pin in Python Script

Post by dirk »

Hi have a look at this snippet here:
viewtopic.php?f=6&t=1626&p=6250&hilit=mirror#p6250
Post Reply