Relay
Overview
Used for switch control, supports controlling Type-A USB devices such as USB fans and small USB appliances.
Technical Specifications
Operating voltage: VCC 3.3V -5V
Module dimensions: 32*48mm
Mounting: 2 plastic building block compatible through-holes
Control mode: Digital input
Pin Definition
Pin |
Definition |
|---|---|
GND |
Ground |
VCC |
Power |
DI |
Digital input |
NC |
Not connected |
Usage Guide
Port |
Function Description |
|---|---|
Micro USB port |
External power supply required when connecting USB-powered devices |
Type-A USB port |
For controlled low-power USB devices; requires MicroUSB power when in use. High level connects USB VDD to MicroUSB VDD, outputting +5V; low level disconnects, no voltage output |
Terminal block IN+ |
Controlled device positive terminal. Normally disconnected from OUT+, closes on signal |
Terminal block IN- |
Controlled device negative terminal, connected to OUT- |
Terminal block OUT+ |
Controlled device positive terminal. Normally disconnected from IN+, closes on signal |
Terminal block OUT- |
Controlled device negative terminal, connected to IN- |
Example Code
Press button A to turn on the relay; press button B to turn off the relay. Press button A to fire the laser; press button B to turn off the laser.
from mpython import *
p0 = MPythonPin(0, PinMode.OUT)
def on_button_a_pressed(_):
p0.write_digital(1)
button_a.event_pressed = on_button_a_pressed
def on_button_b_pressed(_):
p0.write_digital(0)
button_b.event_pressed = on_button_b_pressed