0

I have an Arduino Uno device that uses the following modules:

  • 16 PIN LED w/ Backlight
  • RFID - RC522 (RFID Reader)
  • HR911105A (LAN Module - HanRun)

These three modules use every digital pin available in the Uno (2-13) and it works correctly. The problem is that I want to add a relay to this board. I am new to Arduino so I use tutorials and right now I do not fully understand how this works. So I have connected the IN pin of the relay to Uno pin 8 and the NO pin of the relay to Uno pin 13.

The problem is that when I don't use other modules the relay works correctly (using this code).

int relay_pin = 8;
int led_pin = 13;

void setup() {
  pinMode(relay_pin,OUTPUT);
  pinMode(led_pin,OUTPUT);
  digitalWrite(led_pin,HIGH);
}

void loop() {
  digitalWrite(relay_pin,HIGH);
  delay(5000);
  digitalWrite(relay_pin,LOW);
  delay(5000);
}

The remaining ports are 1 and 0, which I assume are TX/RX, and can't be used for relay (am I wrong?).

So obviously I should not be using those pins but I wonder which pins I am allowed to use simultaneously when using two or three modules at the same time.

Does it depend on the modules or are there some instructions?

5
  • What are you trying to do with the relay? What drives you to think you want to connect the NO pin to pin 13 of the Arduino?
    – Majenko
    Commented Sep 10, 2017 at 11:21
  • @Majenko Turn on a LED - instructions in here link
    – KababChi
    Commented Sep 10, 2017 at 11:28
  • Ohkay.... that's just ... bizarre.
    – Majenko
    Commented Sep 10, 2017 at 11:28
  • Ah, I see why he thought it would be good to wire it that way - he has no clue about the Arduino's schematics or design and thought there was a resistor on that pin so you wouldn't have to use one. BZZZT. Incorrect. Disconnect the relay from pin 13. You have no reason to want to use that pin. You only need one pin for the relay.
    – Majenko
    Commented Sep 10, 2017 at 11:38
  • @Majenko So i connect one pin straight to GND - other one to pin 8. Right ? and can i use pin 1 or 0 ?
    – KababChi
    Commented Sep 10, 2017 at 11:41

1 Answer 1

0

The relay wiring diagram you are following is just plain bizarre and the strangest one I have ever seen.

Ignore it. It is completely incorrect.

You only need one pin to control a relay, so disconnect it from pin 13.

The switched side can connect to anywhere where you would normally use a switch - such as to switch power to an LED connected between +5V and GND with a suitable current limiting resistor.

You can use any available pin to control the relay, and that includes pins 0 or 1 if you aren't using serial communication. Note that with the relay connected to one of those pins it will most likely activate and buzz while you upload a sketch - best to disconnect it at that point and reconnect it afterwards.


Devices like relays and LEDs need their own dedicated pin. They can't be shared with other functions or each other.

The only devices that can share pins are devices which connect to a bus, such as SPI or I2C.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.