0

I try to use this relay with a Arduino Mega. I connected with jumper cables

  • 5V pin to DC+,
  • GND to DC- and
  • Digital Pin 13 (because its a lucky number) to IN.

The power LED from the relay is lighting green.

I run this code, which should trigger the relay every 3s for 3s:

int pinOut = 13;

void setup() {
  pinMode(10, OUTPUT);
}

void loop() {             
  digitalWrite(pinOut, LOW);
  delay(3000);

  digitalWrite(pinOut, HIGH);
  delay(3000);            
}

When initializing the sketch, the red light (from the relay) is flashing and the relay is clicking. But afterwards nothing happens.

With my multimeter I check the currents:

  • 5V to GND = ~5V
  • Pin13 to GND, when not connected to relay = ~4.7V
  • Pin13 to GND, when connected to relay = ~1.2V

The relay needs 5V and 5mA triggering current. I don't think the Arduino is not suited, since they promote the relay Arduino.

Any ideas? Do I need some kind of resistor? Or is the USB port from the laptop not sufficient? I used two different Arduino Mega's with two different relays. By the way i don't have a big background in electric.

  • 1
    but what do you want with not so lucky 10? – Juraj Mar 6 at 14:40
2

You are using pin 13, but you set pin 10 as an OUTPUT.

pinMode(10, OUTPUT);

Try changing that to

pinMode(pinOut, OUTPUT);

PS by not setting pin 13 to OUTPUT, digitalWrite(pinOut, HIGH); enables the internal pull-up, instead of "connecting" it to 5V. The internal resistors are around 35kOhm. So pulling a bit of current through them will result in a lower voltage at the pin.

  • OMG it is working now. I was trying for hours and in the end it was just a wrong number. Thanks a lot. – WitheShadow Mar 6 at 14:59
  • We've all been there. (-; – Gerben Mar 6 at 15:36
  • There but for the grace of god go I. The hardest bugs to fix are ones where you see what you expect to see, not what's there. Good catch. (Voted) – Duncan C Mar 6 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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