My goal is to flash lights around the house on and off to the beat of a song.

When doing this with a mini LED and an arduino, it works perfectly with a "flash_time" of ~.1 seconds.

This means every .1 seconds a new signal (1 or 0) is passed from the arduino digital pin 3 based on a numerical analysis of the song data I preformed previously.

However, I tried it with a solid state relay and a strobe lights and its not working.

The problem is, I can't flash on and off the lights every .1 seconds. In fact, from testing it, the most I can do is ~every 1 second on and .2 seconds off. Otherwise, the "on" information is too late getting to the lights and finally turning on when it is supposed to be off, and this delay increments making the whole thing a mess.


In regards to the code, I used Python through Pyfirmata:

from pyfirmata import Arduino, util
from time import sleep

ledPin=board.get_pin(f'd:{pin}:p') #digital, pin, pwm
it = util.Iterator(board)

for i in range(10):
    sleep(1) #these values I adjusted and visually determined the minimum

Clearly, I am new to electronics. So please try to spell out all terminology and concepts the best you can.

  • \$\begingroup\$ Have you tried programming the Arduino itself to flash the lights? That will show whether it's a problem with the Arduino--relay part, or whether it's a problem with the Python--Arduino part. \$\endgroup\$ – user253751 May 8 '19 at 5:04
  • \$\begingroup\$ I doubt it is a python implementation issue because it worked with the LED directly without issue but I will try coding the arduino directly (or just use blink for a short time frame) and get back to you when I get a chance. \$\endgroup\$ – James Carter May 8 '19 at 5:06

If you buy your parts from proper suppliers, they will provide dasheets for things like your relay.

Checking the datasheet for the relay,we find this bit of information on the switching time:

enter image description here

You are using a 210B relay, so it should take it at most ((1 second / 60 Hz)/2 +1 millisecond)= 17 milliseconds to turn on. It should take at most (3*(1 second / 60 Hz)/2 +1 millisecond)= 26 milliseconds to turn off.

That's on and off at 23 times per second, so the relay should be fast enough.

Now lets look at the LEDs. This is a consumer article rather than something you would buy from an electronics supplier. The only "specifications" available are whatever the seller feels like putting in his advertisement.

The key point is that your string of LEDs is microprocessor controlled, and that you seem to be controlling it by switching the AC power on and off.

The output from the transformer doesn't shut off immediately when you disconnect it from AC.

The LEDs don't go on immediately when the power comes on because the processor has to start up and prepare to do its thing (it flashes the LEDs itself normally.)

What you'll have to do is to leave the AC adapter plugged in all the time. Cut the wire feeding the LED after the transformer, and put your relay in series with that. Set thr controller to "always on" and you should be able to flash your LEDs at speed.

That assumes that the LEDs are "stupid." There are LEDs that contain a small processor themselves, and you can't just chop their power and be happy.

In that case, you need a different string of LEDs with plain old fashioned stupid LEDs.

  • \$\begingroup\$ Thank you for your response. You were correct in that I was switching on and off the AC power upstream the processor. I stripped the wire and connected it downstream the processor and left the AC power in, but now the lights will not turn on. The power to the relay from my arduino is working based on the LED on the relay. Any idea what might be causing this? The relay is in series and I flipped the leads in case it is polarized. \$\endgroup\$ – James Carter May 11 '19 at 2:46
  • \$\begingroup\$ I found a better close up of the controller. It looks like it has "smart" LEDs. Either you'll have to make your own controller (if you can figure out how to send comnands to the ones you've got) or you need a string of simple LEDs that just light up in one color. \$\endgroup\$ – JRE May 11 '19 at 7:40
  • \$\begingroup\$ I got a set of simple LEDs and everything works great. Thank you for your help! \$\endgroup\$ – James Carter May 14 '19 at 11:08

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.