The 1 Channel 5V Relay Module is an electronic switch that allows you to control high power devices with a low voltage signal, typically from a microcontroller like an Arduino. This relay module is widely used in robotics, home automation, and various DIY projects where it is necessary to control AC or DC loads.
Pin | Description |
---|---|
VCC | Connect to 5V power supply |
GND | Connect to ground |
IN | Control signal input from microcontroller |
NO | Normally open contact |
COM | Common contact |
NC | Normally closed contact |
// Define the relay control pin
const int relayPin = 2;
void setup() {
// Set the relay pin as an output
pinMode(relayPin, OUTPUT);
// Start with the relay off
digitalWrite(relayPin, LOW);
}
void loop() {
// Turn on the relay
digitalWrite(relayPin, HIGH);
delay(5000); // Keep the relay on for 5 seconds
// Turn off the relay
digitalWrite(relayPin, LOW);
delay(5000); // Keep the relay off for 5 seconds
}
Q: Can I control this relay with a 3.3V signal? A: The relay might not reliably trigger with 3.3V. It is designed for 5V signals.
Q: Is it safe to control AC devices with this relay? A: Yes, but ensure you have proper knowledge of working with high voltage and take necessary safety precautions.
Q: Can I use PWM to control the relay? A: No, the relay requires a steady HIGH or LOW signal to change states. PWM may cause erratic behavior.