• Why not take a moment to introduce yourself to our members?

Location
Queens
Rating - 100%
9   0   0
First I want to say two things:
I have practically no experience coding. Please bear with me.
I really really appreciate you for reading this very long post and helping me.

The project:
I want to use an analog RGB 5050 LED strip to simulate a sunrise, daytime, sunset and nighttime lighting atmosphere in my fish tank.

I will wire it to the PWM ports on the following Arduino controller:
http://www.amazon.com/SainSmart-ATme...nsmart+arduino

The wiring schematic is as described on this site:
http://learn.adafruit.com/rgb-led-strips/overview


I plan to use the VaRGB library and take advantage of the linear and constant transition curves
http://flyingcarsandstuff.com/projects/vargb/

In the VaRGB guide it mentions using a callback to communicate with the RGB strip.
http://flyingcarsandstuff.com/projec...gramming-vargb

I'm not sure how to get this callback done.

I also plan to use an RTC module such as this:
http://www.amazon.com/SainSmart-DS13...=arduino+clock
or
http://www.amazon.com/SainSmart-DS13...ds=arduino+RTC

How do I integrate this RTC module electrically to the Arduino and also through the code so I can program my VaRGB linear/constant curves based on time.

I'd like to program various curves to run simultaneously for very smooth fading and transition. But I can also run the curves sequentially as I've outlined below.

Basically the color transition would be:
Sunset (opposite for Sunrise)
Start at the end of the constant white curve.
The lights change to a bright yellowish white, then a medium brightness orange, to a dark red, to a twilight blue down to very dim dark blue as a moonlight.
In the morning the RGB spectrum would be (on a 0-256 scale)
Red 0, Green 0, Blue 10 (Moonlight)
I would ramp up to Red 20, Green 0, Blue 10. (Dark Red)
Then I would ramp to Red 30, Green 0, Blue 10. (Medium Red)
Next would be Red 40, Green 30, Blue 15 (Medium Orange)
After that would be Red 50, Green 50, Blue 20 (Yellow)
And from this I would ramp to Red 100, Green 100, Blue 100 (White)
I will be playing around with these colors. This is just an example


I don't know how to do the callback but this is what is on the site:

void MyColorSettingCallback (vargb::ColorSettings * color_values) {

the_brite.sendColor(color_values->red, color_values->green,
color_values->blue);
}

This is assuming I use the TinyBrite library. Would I just remove the "the_brite"?
I don't know what library I would be using.


After setting up the callback you set up the driver like this:

vargb::VaRGB vargb_driver(MyColorSettingCallback);


Also, how would I set the threshold for the PWM on the VaRGB?
i.e. 0-256?
On the VaRGB website they use numbers past 256.

I know this so far:
For the VaRGB coding I would do:
Constant(0,0,0,3600)
Linear(0,0,50,3600)
This would fade blue to 50 from 0 in the duration of one hour.
I would set a line like this for each transition.

Then I would add all the transitions to a schedule:

vargb::Schedule my_schedule;
my_schedule.addTransition(&some_linear_curve);
my_schedule.addTransition(&another_constant_curve);
my_schedule.addTransition(a_pointer_to_the_final_linear_curve);

Then I could set the desired schedule into the driver as:

my_driver.setSchedule(&my_schedule);
 
Location
Montreal
Rating - 0%
0   0   0
Hi,

I probably can't answer all your Qs but hope to shed some light on a couple of things. First off, I apologize as I just registered to answer the question and the system won't let me include URLs...

> How do I integrate this RTC module electrically to the Arduino and also through the code so I can program my VaRGB linear/constant curves based on time.

I couldn't get the links for the RTC module working, but I'm guessing this is some DS1307-based solution. Assuming this is the case, exactly how you hook everything up will depend on the module's specifics but it will entail hooking up the I2C (a two-wire communication protocol) correctly with your Arduino (arduino.cc/en/Reference/Wire shows the pins for various flavours of 'duino). From there, using the RTCLib should make things pretty easy and it has some useful examples (github.com/jcw/rtclib/blob/master/examples/ds1307/ds1307.ino)

In terms of code, AFAIK the DS1307 has second-resolution--it keeps the time, but isn't about being fine grained--whereas VaRGB works by receiving periodic *ticks* at short, regular, intervals (20ms). You _could_ muck about in the VaRGB source to adjust it to expect ticks at a lower frequency, but this would
* risk making some of the transitions a little abrupt
* be a pain in the butt

A better approach, in my opinion, would be to have schedules triggered to start at specific times of day and simply:

* maintain an associative list of times at which you wish to trip a schedule, and the particular schedule in question.

* query the RTC regularly to see if it's time to setup and begin a new schedule, if so do the setSchedule() thing.

Even simpler is to have a single schedule that does everything you need done in a day, that lasts at least 24 hours, and every morning when the RTC says it's time to begin, just my_driver.resetTicks();

You can get fancier, by setting different callbacks to get notified when schedules have completed their run or even when the schedule transitions begin/complete, but I don't think you need these things yet.


> I don't know how to do the callback but this is what is on the site

You can do whatever you want with the color values sent to you by VaRGB in the callback. Let's say you've setup some pins for analog output, for use with the analog version of the LED strip, as described on learn.adafruit.com/rgb-led-strips/example-code

void MyColorSettingCallback (vargb::ColorSettings * color_values) {

analogWrite(REDPIN, color_values->red);
analogWrite(GREENPIN, color_values->green);
analogWrite(BLUEPIN, color_values->blue);
}

and you're done.



> Also, how would I set the threshold for the PWM on the VaRGB? i.e. 0-256?

VaRGB will operate within whatever range you specify, so if none of your settings go beyond 255, VaRGB should never call your callback with a value beyond 255.

Note: remember that this value is to fit in a single byte so the range is 0-255 (inclusive)--256 actually overflows, and would act like 0.

Hope the above will be useful, good luck with your project!
PatD
 
Location
Montreal
Rating - 0%
0   0   0
Final note, if you really do only have a single schedule that you wish to run over the course of a day, the super-simple/cheap solution is to setup your Arduino to run that schedule on startup and use an old fashion wall-wart lamp timer to power the whole thing:circuit-free RTC ;-)

Cheers,
PatD
 

Sponsor Reefs

We're a FREE website, and we exist because of hobbyists like YOU who help us run this community.

Click here to sponsor $10:


Top