Hi all,

Quick run down of what im trying to accomplish. New fishtank, want to simulate lighting patterns. I have blue and white LED strips lighting the tank, need to dim these at certain times of the day.

I break the day into 8 sections (3 hrs each obviously)
The idea is for the pic to start, then count up seconds, minutes, hours, then hour sections, and adjust the hpwm output to suit the particular section.

This is what I have come up with so far, if you could comment that would be appreciated. I'm only very new to all of this so if i can learn tips that would be great.

btw: I have listed 2 colours, i'll simply use 2 pics, or try to find a small say 18pin pic with 2 hpwm.


'===================================
'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2006 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 3/03/2006 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************

'define dutycycle variable
dutyCycle var byte


'define clock variables
minute var byte
hour var byte
second var byte
hs var byte
ledblue var byte
ledwhite var byte

'================================================= =====
'start the main segment
main:


'add a second to the counter
second = second + 1
pause 1000

'check to see if 60 seconds have passed
if second = 60 then endsecond


'HPWM Channel,Dutycycle,Frequency
hpwm 1,ledblue,1000

'end of section, repeat main code.
goto main
'================================================= ======

'click 60 seconds to 1 minute
endsecond:
minute = minute + 1
second = 0
if minute = 60 then endminute
return

'click 60 minutes to 1 hour
'also calculates which program section of the day it is
endminute:
hour = hour + 1
minute = 0
if hour = 24 then
hour = 0
end if

if hour = 0 then hs = 0
if hour = 3 then hs = 1
if hour = 6 then hs = 2
if hour = 9 then hs = 3
if hour = 12 then hs = 4
if hour = 15 then hs = 5
if hour = 18 then hs = 6
if hour = 21 then hs = 7

goto selectpwm

return

selectpwm:
select case hs
case 0
ledwhite = 128
ledblue = 75
case 1
ledwhite = 75
ledblue = 128
case 2
ledwhite = 25
ledblue = 50
case 3
ledwhite = 75
ledblue = 50
case 4
ledwhite = 192
ledblue = 50
case 5
ledwhite = 255
ledblue = 36
case 6
ledwhite = 255
ledblue = 25
case 7
ledwhite = 224
ledblue = 50
end select
return
'====================================
'====================================

also with the hpwm, what is the ideal rate for the frequency, that 3rd variable.

Cheers guys, let me know if I need to fix anything

Tim.