Click on the components to start interacting it with in the connection area
Hover over the Raspberry Pi connections to get informations about various connections pin
Double click on various connections points to make connections
Double click on the empty space in the connection area to extend and bend wire connections
How To Connect
Connect 3.3 V pin of Raspberry Pi to VCC pin of Relay
Connect GND pin of Raspberry Pi to GND of Relay
Connect GPIO 21 of Raspberry Pi to Input pin of Relay
Connect COM (Common pin) of Relay to +ve Voltage source of Battery
Connect NO pin of Relay to +ve terminal of DC motor
Connect -ve of Voltage source of Battery to -ve terminal of DC motor
Connections Logs
Raspberry Pi
Relay
DC Motor
9v battery
Hover over a component to see its description.
CONNECTOR INFO
import RPi.GPIO as GPIOimport time# Set up GPIOGPIO.setmode(GPIO.BCM)GPIO.setup(relay_pin, GPIO.OUT)# Function to turn on the motordef turn_on_motor(): GPIO.output(relay_pin, GPIO.HIGH) print("Motor ON")# Function to turn off the motordef turn_off_motor(): GPIO.output(relay_pin, GPIO.LOW) print("Motor OFF")try:# Set the GPIO pin for the relay relay_pin = 17 # Main loop while True: turn_on_motor() time.sleep(5) # Run the motor for 5 seconds turn_off_motor() time.sleep(2) # Wait for 2 seconds before turning on againexcept KeyboardInterrupt: # Clean up GPIO on keyboard interrupt GPIO.cleanup()