1
Project development, ideas, and suggestions / Re: Controllable Aquarium Moonlight Strip

(you can use variable capacitor to set light level trigger)
pinb.0 and pinb.1 is pwm for white and blue leds and on pinb.2 is relay for turning on/off Fluorescent lamp.
Program works by turning of fluo lamp 30 seconds after light level in room turns below some level and starts easily fading blue and white led's to random level and then again turning on fluo lamp and turning off led's when light level goes above set light level
Here is hex
http://http://siklosi.users.sbb.rs/MOONLIGHT13.HEX
and here is code:
Code: [Select]
' During programming change lfuse from 6A (default for attiny13) to 7A to disable
' internal clock divide by 8 and avoid flicker of led's
$regfile = "attiny13.dat"
$crystal = 9600000
$hwstack = 32 'hw, sw stack and framesize had to be modified because rnd uses a lot
$swstack = 16 'of memory that attiny13 doesn't have
$framesize = 8
Config Watchdog = 256
Start Watchdog
Dim Pwmb As Byte
Dim Pwmw As Byte
Dim Fotor As Word
Dim T As Byte
Pwmb = 0
Pwmw = 0
T = 0
Tccr0a = &B10100001
Tccr0b = &B00000011
Config Pinb.0 = Output
Config Pinb.1 = Output
Config Portb.2 = Output
Config Pinb.4 = Input
Rele Alias Portb.2
Declare Sub Deadloop
Pwmw = Rnd(255)
Call Deadloop()
Do
Set Portb.2
If Pwmb > Pwm0a Then
Pwm0a = Pwm0a + 1
Else
Pwm0a = Pwm0a - 1
End If
If Pwmw > Pwm0b Then
Pwm0b = Pwm0b + 1
Else
Pwm0b = Pwm0b - 1
End If
Reset Watchdog
If Pwmb = Pwm0a Then
Pwmb = Rnd(255)
Fotor = Getrc(pinb , 4)
'check if light is again high
If Fotor > 50 Then
T = 0
Pwm0a = 0
Pwm0b = 0
Call Deadloop()
End If
End If
If Pwmw = Pwm0b Then Pwmw = Rnd(255)
Waitms 50
Loop
Sub Deadloop()
Do 'do while light is high and 30sec after
Reset Portb.2
Reset Watchdog
Fotor = Getrc(pinb , 4)
If Fotor < 50 Then
Reset Watchdog
T = T + 1
Waitms 180
Else
T = 0
End If
Loop Until T = 60
End Sub
PiratePICprog is intended to do it for PICs on Bus Pirate and FT2232, and AVRs are easy to program.

