Hallo,
ich habe einen Dimmer für ne RGB LED geschrieben. Jetzt würde ich gerne per RC5 einen Wert ( 0 -99 ) eingeben können. Diese Zeit sollte dann die Geschwindigkeit des Dimmvorgangs bestimmen. Momentan löse ich einen Interrupt aus, sobald eine Taste gedrückt wird. Ich komme aber einfach nicht drauf, wie ich so eine Eingabe gestalten könnte. Hier ist mal mein code. Wäre super, wenn mir einer von Euch helfen könnte.
mfg Kay
Code:'---------------------------------------' '### RGB LED Dimmer ###################' '### by Kay Pohl ###################' '### Version 1.0 ###################' '### 21.04.2007 ###################' '---------------------------------------' '--- Chipdefinition ------------------- $regfile = "m8def.dat" $crystal = 16000000 $baud = 9600 $hwstack = 32 $swstack = 16 $framesize = 64 '--- Portdefinition ------------------- Config Portb = Output '--- alias ----------------- Rot Alias Ocr2 Blau Alias Pwm1b Grun Alias Pwm1a '--- RC5 -------------------- Config Rc5 = Pind.3 Config Pind.3 = Input Enable Interrupts '--- Timerkonfiguration / PWM --------- Config Int1 = Falling On Int1 Check_rc5 Enable Int1 Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 8 Config Timer2 = Pwm , Compare Pwm = Clear Up , Pwm = On , Prescale = 8 '--- Ausgangszustand ------------------ Grun = 0 Blau = 0 Rot = 0 '--- Dim´s ---------------------------- Dim Adress As Byte Dim Command As Byte Dim R As Byte Dim G As Byte Dim B As Byte Dim Zeit As Byte Zeit = 10 '--- Hauptprogramm -------------------- Main: Goto Main '--- Check_Rc5 ------------------------ Check_rc5: Disable Int1 Enable Interrupts Getrc5(adress , Command ) If Adress = 5 Then Command = Command And &B01111111 Print Command ; " " ; Adress ; End If Waitms 30 If Command = 1 Then Rot = 255 If Command = 2 Then Grun = 255 If Command = 3 Then Blau = 255 If Command = 12 Then Rot = 0 Grun = 0 Blau = 0 End If If Command = 53 Then Enable Int1 Goto Durchlauf End If If Command = 54 Then Rot = 0 Grun = 0 Blau = 0 Enable Int1 Goto Main End If Enable Int1 Return '--- Durchlauf ------------------------ Durchlauf: '---------------- Verlauf Rot ---------- For R = 0 To 255 Rot = R Waitms Zeit Next R Wait 1 For R = 255 To 0 Step - 1 Rot = R Waitms Zeit Next R '---------------- Verlauf Grün -------- For G = 0 To 255 Grun = G Waitms Zeit Next G Wait 1 For G = 255 To 0 Step - 1 Grun = G Waitms Zeit Next G '----------------- Verlauf Blau ------- For B = 0 To 255 Blau = B Waitms Zeit Next B Wait 1 For B = 255 To 0 Step - 1 Blau = B Waitms Zeit Next B Goto Durchlauf
Lesezeichen