I am using this relay module with arduino nano every board and I want to test it first, how do I connect it?
I tried connecting like:
Wiring the Relay Module:
Relay to Arduino:
VCC: Connect to the 5V pin on the Arduino.
GND: Connect to the GND pin on the Arduino.
IN (Control Signal): Connect to a digital pin on the Arduino (e.g., D4).
Relay Output Connections:
COM (Common): Connect to one terminal of the LED or lamp.
NO (Normally Open): Connect to the positive side of a separate power supply (e.g., 9V battery for an LED or lamp).
Negative side of the power supply: Connect to the other terminal of the LED or lamp.
const int relayPin = 4; // Pin connected to the relay module
void setup() {
pinMode(relayPin, OUTPUT); // Set relay pin as an output
digitalWrite(relayPin, LOW); // Ensure relay is off initially
}
void loop() {
digitalWrite(relayPin, HIGH); // Activate the relay
delay(2000); // Keep the relay on for 2 seconds
digitalWrite(relayPin, LOW); // Deactivate the relay
delay(2000); // Keep the relay off for 2 seconds
}
I recently “reverse engineered” a schematic for a 12 volt relay module with selectable High/Low trigger input. It looks essentially like @LarryD ‘s schematic. The circuit Larry drew will work for “low” trigger mode.
The DC+ terminal has to be whatever voltage your relay module requires (12 per your description, 9 per the provided image). If you use the “low” trigger option you will damage your MCU by switching 12(9?) volts with the output pin. The additional transistor is required to avoid this.
What I don’t like about this type (High/Low selectable trigger) is that it does not allow complete isolation of the MCU wiring from the relay power. A common ground is required. Complete isolation can be achieved by removing the High/Low jumper entirely. Then, with the output pin from the MCU wired to the “In” terminal of the relay module, “High” trigger can be achieved by connecting the MCU ground to the “common” terminal of the selector. For low trigger the 5 volt supply from the MCU should be connected to the “common” terminal. This also eliminates the need for the additional transistor.
Sorry, but your schematic is nonsense garbage. You powered the Nano by 5v to VIN pin.
And you draw an analog input-only pin A7 to control the relay, while use a D7 in the code.
Only someone who doesn't understand arduino at all could draw something like this. Or, more likely, it's a product from ChatGPT that you mindlessly copied into the forum.
@andrewdonaldson177
As I see, you constantly drag all sorts of AI garbage into the forum. This is against the rules of the community. Please, answer with your own mind or better yet, keep quiet if you don't know the answer.
Actually it's called a mistake not sure why I didn't catch that I put it to A7 not D7 I must have been thinking about something else ADHD does that. Arduino Nano boards operate just fine on 5 volts. But since you feel so superior that you need to attempt to insult others in public have a good day. I hope you don't just sit in your room lonely someday after you alienate everyone you knew.