SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By quatro007
#199995
I really like this component and the breakout board but this issue is huge for my product. I'm looking for a way to turn off blinking LEDs once they have been started. It doesn't matter if the blink is initiated in the setup or the loop (I'm using them in the loop): io.blink(sx1509_PIN3, 1000, 1000); .

No matter what I try, I've not yet found a way to turn it off once blink has been initiated. I've tried changing that pinMode to Analog then setting to PWM 0 and I've tried changing the pinMode to output then setting low. The only thing that will change the status is to set the pin high but then when you set it to low again, it goes back to blinking. It's like the registers for that pin blink mode are set and cannot be cleared. I believe I had the same problem with Breath, I could start a pin breathing, but couldn't turn it off.

I have looked through the Sparkfun guides and nothing mentions turning it off. There has got to be a way to turn it off otherwise what's the point of that functionality if you can't control it.

Is there a way to reset that specific output pin?

Any ideas?

Thanks,
Sean
User avatar
By DanV
#200010
You could try :
Code: Select all
  io.blink(my_PIN, 0, 0);
I checked out the github repository and had to look real hard to find (in the .h file):
Code: Select all
setupBlink(byte pin, byte tOn, byte tOff, byte offIntensity, byte tRise, byte tFall):  
//blink performs both the blink and breath LED driver functions 
//		- tOn: the amount of time the pin is HIGH 
//			- This value should be between 1 and 31. 0 is off. 
//		- tOff: the amount of time the pin is at offIntensity 
//			- This value should be between 1 and 31. 0 is off. 
User avatar
By DanV
#200013
Well, don't thank me yet - let's see if that works.
the description of 0 is off is from setupBlink() but I think it's the same for blink().
By quatro007
#200018
Ok, so that code " io.blink(my_PIN, 0, 0); " just makes it blink quickly (maybe 200ms freq). The last lines below are where I'm trying to cancel the blink.
if (pc24p9status == 1 || pc24p12status ==0) // Hazzard Switch or turn signal has been activated
{
io.pinMode(sx1509_PIN3, OUTPUT);
io.blink(sx1509_PIN3, 1000, 1000);
}
else if (pc24p8status ==1) // Front right running light
{
io.pinMode(sx1509_PIN3, ANALOG_OUTPUT);
io.analogWrite(sx1509_PIN3, 125);
}
else //Switch has been de-activated
{
Serial.println("TRYING TO TURN OFF");
io.pinMode(sx1509_PIN3, OUTPUT);
io.blink(sx1509_PIN3, 0, 0);
// io.pinMode(sx1509_PIN3, ANALOG_OUTPUT); // doesn't work
// io.analogWrite(sx1509_PIN3, 255); // doesn't work
}

}

Any other ideas? Thanks in advance!

Sean
By quatro007
#200047
Thanks, I'll try that tonight.

I did try
io.blink(sx1509_PIN3, 5000, 0);

And that works however the 0 on time isn't actually zero, it will blink every 5sec. So I guess if all else fails, I could set the off time to max millis which should give me a few days of off time before it blinks again, but that's a pretty lame way of doing it.

Sean
By quatro007
#200048
It won't compile with the setupBlink and says "setupBlink is not declared in this scope".

And, io.blink(SX1509_PIN3, 0, 0, 0, 0, 0); doesn't work either. It's looking for only two int values after the myPin.

I also changed to a very simplified Uno and SX1509 on a proto board setup blinking an LED to help diagnose (remove all other complexity). All the suggestions so far have been also been tested on this with the same stated results.

Thanks,
Sean
User avatar
By DanV
#200049
I see no reason that setupBlink() would be rejected by the compiler unless you're not using the gitHub library.
I guess you could examine the .h and .cpp file on your computer to see if setupBlink is in there.
It nearly has to be there since blink() and breathe() both call setupBlink().

you did make the call like this, right?
Code: Select all
io.setupBlink(SX1509_PIN3, 0, 0, 0, 0)
since io is your instance of the library.
By quatro007
#200050
Ok, sorry about that, I was missing the "io." it works but the pin goes solid high. That got me thinking about how with this chip sinking and sourcing drive inverse PWM, so PWM 0 is high and PWM 255 is low for my LED configuration. So if it was solid high that meant the setupBlink was possibly resetting it but maybe it was the inverse of what I was thinking. The 3rd byte after the myPin is the onIntensity. So, I changed the line to this..
(io.setupBlink(SX1509_PIN3, 0, 0, 255) the remaining bytes after 255 aren't needed.

AND IT WORKS!!!
By setting that 3rd byte either 0 or 255 I am now able to reset the pin to either solid on or off.
I added a line following that and am able to turn the blink back on. It looks like I can control it now.

Thanks so much for the help, I appreciate it!!!

Sean