after a pretty long break i recently picked up a new Arduino mega for a project i sort of started 6 months ago.

long story short, i started never finished, life took over and it was a job to pick back up, now that i've jsut finished my Uni exams for a few months i thought i'd have another stab.

firstly the first project can be found here:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1269962097/0

the idea was to build my own little reef computer for a pico tank that i set up, unfortunatly july 10 i had to dismantle my pico as it wasnt getting the attention it needed plus going away on holiday etc ment it was for the best. i restarted the pico last month and with it restarted my interest in Arduinos, so i ordered my bits and bobs and would like to have another stab at the project.

i deciced to buy a second Mega so i could work on different aspects of the project before compiling it with my old (which is a mess of breadboards, wires, probes etc)

so without wasting any more time

Ladys and gentle men if you so choose to help.

I want to write a piece of software which utilizes the buckpucks of my DIY led light and fade my led's in via PWM and my RTC chip.once ive got the basics sorted, i would like to incorporate a moon light and possibly have some fun with "random" weather patterns etc.

i've had a bit of a dabble this everning just "relearning the ropes" as it were with coding, the last object orientated programing i did was months a go, and with my poor memory unfortunatly some has slipped

So this is the stage im at so far...

....

yup thats it nothing!

ok not quite,

I hooked up my DIY RTC chip to my arduino and pulled over some test coding and used the sereal monitor to check it all works.

this was only ment to be a 10-15 minute job before starting some more productive coding but for some reason my RTC chip isnt working correctly or atleast my coding.

for some reason my "seconds" wont write properly.when i call the serial monitor up it always starts from 0. edit while typing this entry i realised i needed to hash out the RTC start program after it had been flashed to the RTC chip now we can move onto the fun bit

Sounds like an interesting project. I'll just give a few little basic timing values to maybe get you started. Having a RTC makes it a pretty simple task I think. I will assume you will be using the analogWrite() function to PWM your led brightness.

As the analogWrite() function only has a 0-255 step capacity for dimming of 0-100% brightness, and you wish to fade up or down over a 12 hour period, that means incrementing or decrementing the PWM value every 3 mins, that is close enough I think, (3X256) / 60 = 12.8 hours cycle.

So your sketch needs to keep reading the RTC until it sees a 'start' time and then starts a pwm analogWrite command starting with 0 and incrementing the pwm value every three mins as read from the RTC. You can have o two time frames going if you wished to have some overlap time between the two light assemblies, other wise it's just keep reading the RTC and see when it's time to make a move.

and regarding the time frame you are correct but i mislead you with my description.

i want the leds to fade in from 0-100% over the space fo say 1Hourthen to fade back, but its essentially the same as what you described.

i kinda came up with a solution this mornig in the shower :-?

i was thinking

if i had some code something along the lines of this i'll jsut do it in speak not code

At 8am set boolean blueOn to trueAt 8.30am set boolean whiteOn to trueat midday set boolean blueOn and whiteOn to falseAt 8pm set boolean whiteOff to trueAt 8.30pm set boolean blueOff to trueAt 3.00 Am set boolean whiteOff and BlueOFF to false

then while the arduino is looping call an imade fade object

that has various If statements saying if boolean XYZ is true do this

then the system will jsut fade at its own pace until completed with the parameters being reset at midday and 3am respectively.

What do you guys think? i mean i havent had a chance to play yet but i will do now/within the next hour or so after ive finished tidying up the house

void rtcStart(){ RTC.stop(); RTC.set(DS1307_SEC,1); //set the seconds RTC.set(DS1307_MIN,11); //set the minutes RTC.set(DS1307_HR,13); //set the hours RTC.set(DS1307_DOW,4); //set the day of the week RTC.set(DS1307_DATE,22); //set the date RTC.set(DS1307_MTH,1); //set the month RTC.set(DS1307_YR,11); //set the year RTC.start(); }

i also plan to clean the code up a bit and put it into 2 objects purely so i can help break the code into segments!

cleaned up and now on version 1.01. ive added the abillity for the user to define the led intensity as a percentage from 0-100% currently by code which is then converted from a percentage into a PWM value.

(in the finished verion or the next version i will add a screen and buttons that enable the user to set the intensity on the fly, might do that next as ive got various lcds and an lcd shield)

also another point if I multiply an Int by a float its possible to get the occational float value, will that automatically be parsed into an int? i.e. rounded up. im assuming so .... need to plug it in and see what happens.

edit also realised a bit of code error in the fade code, so im just looking at that too.

i've managed to fix the majority of the code, infact most of that code above needed re-writing/ tweeking.

im just testing it a bit more then i'll start looking into intergrating an LCD and buttons.

once ive got the fade to work correctly (im sure its just some of my syntax) i'll post the latest code.

edited later:

Well here we are at the moment, i've managed to write the correct code which fades leds in and out at user defined times.

The next stage is to incroperate an LCD and buttons, so i can write code for a menu system that enables the user to set the Maximum led intensity values (fadeMaxWhite and fadeMaxBlue) and then write code that enables the user to define what time they would like the various lights to come on and off at.

Then from there id like to rig a Moonlight, with a 1 watt led maybe. or possibly play with LED matrix's for random weather patterns maybe.

Well i've managed to wire up a basic 1602 LCD screen that 16 char by 2.so im now just meshing the LCD screen and my LED code. I also want to write some code that uses some basic push buttons as input buttons, then i'll write my menu code.

Its kinda nice how quick some of this coding is coming back to me, plus had some fun decyfering the datasheet for this lcd, doing a bit of soldering etc.