I am working on a project where I need to light a 5 meter led strip. There is example code for Arduino that can be found here…
Arduino Code | RGB LED Strips | Adafruit Learning System.
but since I have a gadgeteer board, I want to light them up with my existing board.
I am having a hard time understanding what method to use, the example code above uses pwm technique, they connected all three channels R,G,B to the pwm pins on ardruino and then used analogwrite to control the intensity of lights.
I can do the same on gadgeteer board ( connect all three channels R,G,B to the pwm cabaple socket) but I don’t know how to control their intensity and which method to use, can you please provide me with some sample code on how to get it done or guide me in the right direction.
Thank you for your kind help
Think about what you just wrote:
Then ask yourself what a PWM output does? It changes the duty cycle out the output, i.e. the percentage of time the pin is on vs. off. I don’t know how your device works but since it has three (R, G, B) PWM inputs it would seem that by varying the duty cycle of those signals you change the amount of each of these R, G, B light emitted thus the color of light from the strip would change.
the more important page is probably
If you intend to drive the strip with PWM, this is also required.
Simplistically the circuit they drive is using PWM to provide a rapid on/off logic switching @ 3v3 onto the MOSFET, which puts a rapidly switching 12v output onto the LED. This “simulates” an analog voltage because our eyes think that the LEDs are at a certain brightness but in real terms are being switched on/off; if you increase the amount of ON time per second, they appear brighter, and if you increase the OFF time they appear dimmer. So you get this effect as you ramp the PWM period up and down of brighter and darker.
So step 1 is to get your circuit in order. Once you have that, you just need a PWM pin. The Gadgeteer socket specs will show you what pins are actually PWM enabled, and then you’d need one of the Gadgeteer breakout board options to get simple access to the pins in question. The code is relatively simple to use PWM after that… but let us know how much of the other stuff you have already in place
The lights are not here yet so I am just doing my research in advance, i’ll have them hook up once they are here.
I guess I am confused on what values to pass to the setPulse method.
the example code on adafruit looks pretty simple, they just use the analogwrite method and pass a value from 0,255 which
controls the intensity of light and creating different light spectrums based on those values, I am confused on what values to pass
I am working on a commercial design just now using high power LED’s for underwater lighting and the PWM is dead easy to use.
Simply create the PWM with your desired frequency and on the constructor, set the duty cycle to 0.0 and the invert to FALSE if you want a HIGH pulse as the normal output state.
Now, as an example to set 50%, set the DutyCycle parameter to 0.5 and there you go. No need to play around with the SetPulse method.
The range for the duty cycle is 0.0 to 1.0 for 0 to 100%
Thanks for the quick reply…
Sorry i am a total beginner at this, i understand the fact that the range for duty cycle is between 0 and 1 but
the range for rgb is from 0,255 and mixing those numbers give you a different color…
0-1 or 0-255? i am kinda confuse on that, how would i get a different color when the range is only from 0-1
0 to 1 in PWM simply gives you a per-channel (so one each for red, Green, Blue) intensity, which is 0% to 100%, or the equivalent of (0/255) to (255/255) - so if X is your G channel percentage, you use X/255.0 to get the PWM (0 to 1) value.