Dieser RGB Controller ist ein preiswerter Bausatz, der als Steuergerät für Farbverläufe und Standfarben mittels moderner LEDs dient. Es können über 16 Millionen Farben erzeugt werden. Der Mini-RGB-Fader eignet sich ideal für einfache Farbverläufe und Farblichtbeleuchtungen im Dekorations-, Show- und Wellnessbereich.
Der Mini-RGB-Fader kann über drei verschiedene Ausgänge Mehrfarb-LEDs so ansteuern, dass sich deren nach dem RGB-Prinzip resultierende Mischfarbe automatisch in einem einstellbaren Zeitintervall (ca. 0,5 Sek. bis 4,5 Std.) ändert. Zusätzlich kann man mit dem Farbwechsler im Manuell-Mode eine beliebige Farbe einstellen, um so ein bestimmtes Ambiente zu schaffen. Der Mini-Fader eignet sich ideal für Farblichtbeleuchtungen im Dekorations- und Wellnessbereich. Für den Mini-Fader gibt es aktuell 2 Programme, das Standard-Programm und ein Aquarium-Programm. Klicken Sie bitte die Links um mehr darüber zu erfahren. Die genauen Programmbeschreibungen finden Sie in den Reitern oben. Der Controller besitzt eine ISP Schnittstelle mit der man, sofern man dies kann, den µC selbst beliebig programmieren kann. Ausführliche Infos, technische Daten und Anleitungen zum Bausatz entnehmen Sie bitte der Anleitung im Downloadbereich!
'############################################################################## '####################################Konfiguration############################# '############################################################################## '################### 'Grundeinstellungen# '################### $regfile = "attiny2313.dat" $crystal = 4000000 $hwstack = 32 $swstack = 32 $framesize = 32 '###################################### 'IOs einstellen und Pullups aktivieren# '###################################### Ddra = &B00000000 Ddrb = &B00011000 Ddrd = &B00000010 Porta = &B11111111 Portb = &B11100111 Portd = &B11111101 '############################### 'Hardwarekomponenten definieren# '############################### Config Timer0 = Timer , Prescale = 8 Config Timer1 = Pwm , Pwm = 10 , Prescale = 8 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down Pwm2 Alias Pwm1b Pwm1 Alias Pwm1a Rc5_pin Alias Pinb.2 Dev_add_set_pin Alias Pinb.5 On Timer0 Rc5_isr '############################## 'Interruptsroutinen definieren# '############################## '##################### 'Variablen einstellen# '##################### '---Allgemeine Variablen--- Dim Device_adress As Byte Dim Dimm_counter(2) As Byte Dim Dimm_const(2) As Byte Dim Channel(2) As Word Dim Pre_pwm(2) As Word Dim Controll_byte(2) As Byte Dim Get_value As Byte 'byte-1 bit-0 = 100% Switcher 'byte-1 bit-1 = 1- oder 2-Kanalbetrieb Bit 'byte-1 bit-2 = unbenutzt 'byte-1 bit-3 = unbenutzt 'byte-1 bit-4 = unbenutzt 'byte-1 bit-5 = unbenutzt 'byte-1 bit-6 = unbenutzt 'byte-1 bit-7 = unbenutzt 'byte-2 bit-0 = unbenutzt 'byte-2 bit-1 = Kanal 1 Hochdimm-Bit 'byte-2 bit-2 = Kanal 2 Hochdimm-Bit 'byte-2 bit-3 = Kanal 1 Herunterdimm-Bit 'byte-2 bit-4 = Kanal 2 Herunterdimm-Bit 'byte-2 bit-5 = unbenutzt 'byte-2 bit-6 = unbenutzt 'byte-2 bit-7 = unbenutzt '############## 'RC5 Variablen# '############## Const Timervorgabe = 180 'Timeraufruf alle 178µs (10 Samples = 1 Bit = 1,778ms) Const Samples_early = 8 Const Samples_late = 12 Const Samples_min = 3 Dim Sample As Byte Dim Ir_lastsample As Byte Dim Ir_bittimer As Byte Dim Ir_data_tmp As Word Dim Ir_bitcount As Byte Dim Address_rc5 As Byte Dim Command_rc5 As Byte Dim Got_rc5 As Byte '########################### 'EEPROM Variablen festlegen# '########################### Dim Ee_bugbyte As Eram Byte Dim Ee_init_byte As Eram Byte Dim Eram_channel(2) As Eram Word Dim Eram_controll_byte(1) As Eram Byte Dim Eram_device_adress As Eram Byte '######################## 'EEPROM Daten vorbelegen# '######################## If Ee_init_byte = 255 Then Eram_channel(1) = 511 Eram_channel(2) = 511 Eram_controll_byte(1) = 0 Eram_device_adress = 0 Ee_init_byte = 0 End If '################# '#EEPROM einlesen# '################# Channel(1) = Eram_channel(1) Channel(2) = Eram_channel(2) Controll_byte(1) = Eram_controll_byte(1) Device_adress = Eram_device_adress Declare Sub Sub_pwm_out Declare Sub Sub_get_const_value Declare Sub Sub_incr_channel Declare Sub Sub_decr_channel Declare Sub Sub_reset_controll_byte_2 Declare Sub Sub_reset_controll_byte_2_1 Declare Sub Sub_reset_controll_byte_2_2 Declare Sub Sub_reset_controll_byte_2_3 Declare Sub Sub_reset_controll_byte_2_4 Declare Sub Sub_reset_controll_byte_213 Declare Sub Sub_reset_controll_byte_224 Enable Timer0 Enable Interrupts '##################################################################################### '#################################### Hauptprogramm ################################## '##################################################################################### Do If Got_rc5 = 1 Then Command_rc5 = Command_rc5 And &B01111111 If Dev_add_set_pin = 0 Then Device_adress = Command_rc5 Eram_device_adress = Device_adress Else If Address_rc5 = Device_adress Then Select Case Command_rc5 Case 1 : Channel(1) = Eram_channel(1) 'Speicherwerte von Kanal 1 laden Sub_reset_controll_byte_2 Case 12 : Channel(1) = Eram_channel(1) 'Speicherwerte von Kanal 1 laden Sub_reset_controll_byte_2 Case 13 : Toggle Controll_byte(1).0 'wechseln zwischen Licht 100% und Dimmer Sub_reset_controll_byte_2 Case 16 : 'Kanal 2 hochdimmen Toggle Controll_byte(2).2 Sub_reset_controll_byte_2_4 Case 17 : 'Kanal 2 runterdimmen Toggle Controll_byte(2).4 Sub_reset_controll_byte_2_2 Case 22 : Channel(2) = Eram_channel(2) 'Speicherwerte von Kanal 2 laden Sub_reset_controll_byte_2 Case 32 : 'Kanal 1 hochdimmen Toggle Controll_byte(2).1 Sub_reset_controll_byte_2_3 Case 33 : 'Kanal 1 runterdimmen Toggle Controll_byte(2).3 Sub_reset_controll_byte_2_1 Case 51 : 'Werte Speichern Eram_channel(1) = Channel(1) Eram_channel(2) = Channel(2) Eram_controll_byte(1) = Controll_byte(1) Case 52 : Channel(1) = 511 Sub_reset_controll_byte_213 Case 53 : Channel(2) = 511 Sub_reset_controll_byte_224 Case 54 : Channel(1) = 0 Sub_reset_controll_byte_213 Case 55 : Channel(2) = 0 Sub_reset_controll_byte_224 Case 56 : Toggle Controll_byte(1).1 'wechseln zwischen 2-Kanal und 1-Kanal Betrieb Case 57 : Ee_init_byte = 255 'Werkseinstellung Case 80 : Channel(1) = 511 Sub_reset_controll_byte_213 Case 81 : Channel(1) = 0 Sub_reset_controll_byte_213 Case 82 : 'Werte Speichern Eram_channel(1) = Channel(1) Eram_channel(2) = Channel(2) Eram_controll_byte(1) = Controll_byte(1) Case 85 : Channel(2) = 0 Sub_reset_controll_byte_224 Case 86 : Channel(2) = 511 Sub_reset_controll_byte_224 Case 87 : Ee_init_byte = 255 'Werkseinstellung Case 126 : Channel(2) = Eram_channel(2) 'Speicherwerte von Kanal 2 laden Sub_reset_controll_byte_2 End Select End If End If Got_rc5 = 0 End If If Controll_byte(2).1 = 1 Then Get_value = 1 Sub_get_const_value Sub_incr_channel End If If Controll_byte(2).2 = 1 Then Get_value = 2 Sub_get_const_value Sub_incr_channel End If If Controll_byte(2).3 = 1 Then Get_value = 1 Sub_get_const_value Sub_decr_channel End If If Controll_byte(2).4 = 1 Then Get_value = 2 Sub_get_const_value Sub_decr_channel End If Sub_pwm_out Loop End '##################################################################################### '############################### Timer Interruptroutinen ############################# '##################################################################################### '############## 'RC5 Interrupt# '############## Rc5_isr: '152µs Timer0 = Timervorgabe If Dimm_counter(1) < 255 Then Incr Dimm_counter(1) If Dimm_counter(2) < 255 Then Incr Dimm_counter(2) Sample = Not Rc5_pin If Ir_bittimer < 255 Then Incr Ir_bittimer If Ir_lastsample <> Sample Then If Ir_bittimer <= Samples_min Then Ir_bitcount = 0 Else If Ir_bittimer >= Samples_early Then If Ir_bittimer <= Samples_late Then Shift Ir_data_tmp , Left , 1 Ir_data_tmp = Ir_data_tmp + Sample Incr Ir_bitcount Else Ir_bitcount = 1 Ir_data_tmp = Sample End If Ir_bittimer = 0 End If End If If Ir_bitcount = 1 Then Ir_bitcount = Ir_data_tmp.0 If Ir_bitcount >= 14 Then Command_rc5 = Ir_data_tmp Shift Ir_data_tmp , Right , 6 Address_rc5 = Ir_data_tmp And &B00011111 Command_rc5.6 = Not Ir_data_tmp.6 Command_rc5.7 = Ir_data_tmp.5 Got_rc5 = 1 Ir_bitcount = 0 End If End If Ir_lastsample = Sample Return '################################################################################# '#################################### Sub Routinen ################################### '################################################################################# Sub Sub_get_const_value Dimm_const(get_value) = 35 '20 'If Channel(get_value) < 512 Then Dimm_const(get_value) = 35 If Channel(get_value) < 256 Then Dimm_const(get_value) = 70 If Channel(get_value) < 128 Then Dimm_const(get_value) = 125 If Channel(get_value) < 64 Then Dimm_const(get_value) = 250 End Sub Sub Sub_incr_channel If Dimm_counter(get_value) >= Dimm_const(get_value) Then If Channel(get_value) < 1023 Then Incr Channel(get_value) Else If Get_value = 1 Then Sub_reset_controll_byte_2_1 If Get_value = 2 Then Sub_reset_controll_byte_2_2 End If Dimm_counter(get_value) = 0 End If End Sub Sub Sub_decr_channel If Dimm_counter(get_value) >= Dimm_const(get_value) Then If Channel(get_value) >= 1 Then Decr Channel(get_value) Else If Get_value = 1 Then Sub_reset_controll_byte_2_3 If Get_value = 2 Then Sub_reset_controll_byte_2_4 End If Dimm_counter(get_value) = 0 End If End Sub Sub Sub_reset_controll_byte_2 Sub_reset_controll_byte_2_1 Sub_reset_controll_byte_2_2 Sub_reset_controll_byte_2_3 Sub_reset_controll_byte_2_4 End Sub Sub Sub_reset_controll_byte_213 Sub_reset_controll_byte_2_1 Sub_reset_controll_byte_2_3 End Sub Sub Sub_reset_controll_byte_224 Sub_reset_controll_byte_2_2 Sub_reset_controll_byte_2_4 End Sub Sub Sub_reset_controll_byte_2_1 Controll_byte(2).1 = 0 End Sub Sub Sub_reset_controll_byte_2_2 Controll_byte(2).2 = 0 End Sub Sub Sub_reset_controll_byte_2_3 Controll_byte(2).3 = 0 End Sub Sub Sub_reset_controll_byte_2_4 Controll_byte(2).4 = 0 End Sub Sub Sub_pwm_out If Controll_byte(1).0 = 1 Then Pre_pwm(1) = 1023 Pre_pwm(2) = 1023 Else Pre_pwm(1) = Channel(1) Pre_pwm(2) = Channel(2) End If If Controll_byte(1).1 = 1 Then Pwm1 = Pre_pwm(1) Pwm2 = Pre_pwm(1) Else Pwm1 = Pre_pwm(1) Pwm2 = Pre_pwm(2) End If End Sub
'Den verwendeten µC nennen $regfile = "attiny2313.dat" $crystal = 1000000 $hwstack = 32 $swstack = 16 $framesize = 16 'IO Pins von PortB einstellen Ddra = &B00000000 Ddrb = &B00011100 Ddrd = &B00000000 Porta = &B11111111 Portb = &B11100011 Portd = &B11111111 'Die Timer auf PWM-Modus stellen 'Diese PWM-Register haben eine Breite von 8 Bit - also Werte von 0 bis 255 'Wobei 0 = 0% Helligkeit und 255 = 100% Helligkeit bedeuten Config Timer0 = Pwm , Pwm = On , Prescale = 8 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down Config Timer1 = Pwm , Pwm = 8 , Prescale = 8 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down 'Timerinterruptroutine zuweisen On Timer0 Time_isr 'Die PWM-Register zuweisen Pwm3 Alias Pwm0a Pwm2 Alias Pwm1a Pwm1 Alias Pwm1b 'Tastervariablen den Pins zuweisen S5 Alias Pind.6 S3 Alias Pinb.0 S4 Alias Pinb.1 S2 Alias Pina.0 S1 Alias Pina.1 S6 Alias Pind.3 S8 Alias Pind.2 Hr Alias Pinb.6 'Die Timer freigeben Enable Timer1 Enable Timer0 Enable Interrupts 'ein Paar Variablen Deklarieren Dim Led1 As Byte Dim Led2 As Byte Dim Led3 As Byte Dim Actual_time As Long Dim Dimmen_count As Long Dim Switch_time(4) As Long Dim R As Byte Dim B As Byte Dim G As Byte Dim Delay_a As Long Dim Led_max As Byte Dim Controll_byte As Byte ' Bit 0 = manuell light state ' Bit 1 = time state ' Bit 2 = light state Dim Eep_bugbyte As Eram Byte Dim Eep_init_byte As Eram Byte Dim Eep_switch_time(4) As Eram Long Dim Eep_delay_a As Eram Long Dim Eep_r As Eram Byte Dim Eep_g As Eram Byte Dim Eep_b As Eram Byte Dim Eep_led_max As Eram Byte If Hr = 0 Then Eep_init_byte = 255 If Eep_init_byte = 255 Then Eep_switch_time(1) = 0 Eep_switch_time(2) = 5273438 Eep_switch_time(3) = 7031250 Eep_switch_time(4) = 12304688 Eep_delay_a = 1953 Eep_r = 2 Eep_g = 0 Eep_b = 1 Eep_led_max = 255 Eep_init_byte = 0 End If Switch_time(1) = Eep_switch_time(1) Switch_time(2) = Eep_switch_time(2) Switch_time(3) = Eep_switch_time(3) Switch_time(4) = Eep_switch_time(4) Delay_a = Eep_delay_a R = Eep_r G = Eep_g B = Eep_b Led_max = Eep_led_max 'Die LEDs einstellen, für den Start Led1 = 0 Led2 = 0 Led3 = B 'Hauptprogramm Do Debounce S1 , 0 , S1_sub , Sub Debounce S2 , 0 , S2_sub , Sub Debounce S3 , 0 , S3_sub , Sub Debounce S4 , 0 , S4_sub , Sub Debounce S5 , 0 , S5_sub , Sub Debounce S6 , 0 , S6_sub , Sub Debounce S8 , 0 , S8_sub , Sub If Actual_time < Switch_time(1) Then Controll_byte.2 = 0 If Actual_time > Switch_time(1) Then If Actual_time < Switch_time(2) Then Controll_byte.2 = 1 End If If Actual_time > Switch_time(2) Then If Actual_time < Switch_time(3) Then Controll_byte.2 = 0 End If If Actual_time > Switch_time(3) Then If Actual_time < Switch_time(4) Then Controll_byte.2 = 1 End If If Actual_time > Switch_time(4) Then Controll_byte.2 = 0 If Controll_byte.2 = 1 Then If Controll_byte.1 = 1 Then If Led1 < Led_max Then Incr Led1 If Led1 > R Then If Led2 < Led_max Then Incr Led2 End If If Led1 > B Then If Led3 < Led_max Then Incr Led3 End If If Led1 > Led_max Then Decr Led1 If Led2 > Led_max Then Decr Led2 If Led3 > Led_max Then Decr Led3 Controll_byte.1 = 0 End If End If If Controll_byte.2 = 0 Then If Controll_byte.1 = 1 Then If Led1 > 0 Then Decr Led1 If Led2 > 0 Then Decr Led2 If Led3 > B Then Decr Led3 If Led3 < B Then Incr Led3 Controll_byte.1 = 0 End If End If If Dimmen_count >= Delay_a Then Controll_byte.1 = 1 Dimmen_count = 0 End If If Controll_byte.0 = 1 Then Pwm1 = 255 Pwm2 = 255 Pwm3 = 255 Else Pwm1 = Led1 Pwm2 = Led2 Pwm3 = Led3 End If Loop End Time_isr: Incr Actual_time 'Zeitzähler hochzählen, pro Zählwert 4,096ms If Actual_time > 21093750 Then Actual_time = 0 'Wenn der Zeitzähler 24 Stunden erreicht hat, dann auf 0 setzen Incr Dimmen_count Return S8_sub: Toggle Controll_byte.0 Return S2_sub: Eep_b = Led2 Return S1_sub: Delay_a = Actual_time Eep_delay_a = Delay_a Return S6_sub: Switch_time(3) = Actual_time Eep_switch_time(3) = Switch_time(3) Return S3_sub: Switch_time(4) = Actual_time Eep_switch_time(4) = Switch_time(4) Return S4_sub: Switch_time(1) = Actual_time Eep_switch_time(1) = Switch_time(1) Return S5_sub: Switch_time(2) = Actual_time Eep_switch_time(2) = Switch_time(2) Return