Hello Everyone,
I have connected a simple relay module to my Nano board. The connections are as below:-
VCC → 5 volt pin
GND → Ground pin
IN → GPIO 21
As soon as I make the connections, the relay goes HIGH (switched ON).
I am running the following code but it makes no difference.
But when I make the same connections on raspberry Pi, the relay is NOT HIGH (not Turned ON) and the code works perfectly fine.
I want a working code for switching relay ON for my Jetson Nano. Can somebody please help?
CODE:
import RPi.GPIO as GPIO
import time
channel = 21
GPIO setup
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel, GPIO.OUT)
def motor_on(pin):
GPIO.output(pin, GPIO.HIGH) # Turn motor on
def motor_off(pin):
GPIO.output(pin, GPIO.LOW) # Turn motor off
if name == ‘main’:
try:
motor_on(channel)
time.sleep(1)
motor_off(channel)
time.sleep(1)
GPIO.cleanup()
except KeyboardInterrupt:
GPIO.cleanup()