relays operating backwards...I think

I have an Arduino Mega running a program that sends digital outputs in different combinations that I am using to flash strings of Christmas lights. I wrote my program over this past winter and it works exactly like I want when I use it to power LEDs on a breadboard. However, this past week I have wired up the receptacles and relays I am using to actually run the strings of lights, and everything is operating backwards. All of the lights flash just fine, except they’re on when my output is LOW and off when my output is HIGH.

I have the wiring going to the normally open contacts on the relays, and like I said the same program works just fine with LEDs on a breadboard. What am I doing wrong here? Seems to me like I’m missing something silly.

This is the relay board I’m using: http://www.ebay.com/itm/5v-Eight-8-Channel-DC-5V-Relay-Switch-Module-for-Arduino-Raspberry-Pi-ARM-AVR/231682185473?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2060353.m2749.l2649

I attached a sketch of how I have stuff wired up.

Thanks!

Most, but not all, relay boards operate that way. Reverse the pin logic in your program so LOW turns on the relay.

Paul

I'm guessing that when you have it driving leds, those leds are from an output pin to ground, so they're on when the pin is high. But the led in the optoisolator on the relay board is wired from Vcc to your pin, so that led is on when your pin is low.

UIltimately that led in the opto being on is what causes another transistor to go on and energise the relay, so yeah, a low on your pin energises the relay.

I have the wiring going to the normally open contacts on the relays,

So the easiest fix is to switch to the NC contacts.

Or, you can re-write your software if you don't want the lights to be on when the relays are de-energized.

...Sometimes when you buy cheap stuff from unknown manufacturers on eBay, you don't get the specs. :wink:

BTW - Something similar happens with a switch & pull-up resistor on an input... When the switch is off, input is high and when the switch is on the input is pulled-low. It "feels" backwards, but you just take care of it in software (if necessary). And, you might have to mount the switch upside-down.

Thank you all for the replies. I’ll just reverse it and be done then. I’m glad there is nothing actually wrong.

DVDdoug:
…Sometimes when you buy cheap stuff from unknown manufacturers on eBay, you don’t get the specs. :wink:

Haha! This is true, but I was more worried about cheap than about specs. :slight_smile:

DVDdoug:
Something similar happens with a switch & pull-up resistor on an input... When the switch is off, input is high and when the switch is on the input is pulled-low. It "feels" backwards

And that's why it might be better not to think of the switch as off/on but open/closed and the plant (led, motor, whatever) as the thing that's off or on.