Thonny code to Node-Red

#1

So im am using the code below in thonny and am now trying to make it in a Node-red flow .

I'm not really familiar with coding so I dont know how it all work.
thank you in advance.

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)    
GPIO.setup(16,GPIO.IN)

try:
    while True:
    if GPIO.input(16)==0:
        print ("Open")
    else:
        print ("Closed")

finally:
    GPIO.cleanup()
0 Likes

#2

Already found it.
I just seached in google

0 Likes