Config Timer0 = Timer , Prescale = 1 Config Portb = Output On Ovf0 Tim0_isr Enable Interrupts Enable Timer0 Start Timer0 Dim R1 As Byte Dim G1 As Byte Dim B1 As Byte Dim B As Byte Dim R As Byte Dim G As Byte Dim Ri1 As Byte Dim Gi1 As Byte Dim Bi1 As Byte Dim Z As Byte Dim J As Byte Dim C As Word Dim ___rseed As Word Dim Summe As Word Dim Summe1 As Word C = 20 Main: Do If R1 > R Then Incr R 'Pwm werte an Zufallswerte langsam angleichen If G1 > G Then Incr G If B1 > B Then Incr B If R1 < R Then Decr R If G1 < G Then Decr G If B1 < B Then Decr B If R1 = R And G1 = G And B1 = B Then Goto Readnext 'wenn gleich hole neue Zufallswerte Waitms C Loop Readnext: 'Zufallswerte werden generiert mit einer 'Summe von mindestens 51 Do ___rseed = Timer0 R1 = Rnd(255) G1 = Rnd(255) B1 = Rnd(255) Summe1 = R1 + G1 Summe = Summe1 + B1 If Summe > 50 Then Goto Main Loop Tim0_isr: 'THX to http://www.smartprogramming.de/ If Z = 0 Then 'Gewünschte Ausgabewerte an Ri1 = R 'Hilfsregister übergeben Gi1 = G Bi1 = B Z = 255 End If Z = Z - 1 'PWM Kanäle If Ri1 > 0 Then Portb.0 = 0 Else Portb.0 = 1 End If Ri1 = Ri1 - 1 If Ri1 = 255 Then Ri1 = 0 If Gi1 > 0 Then Portb.1 = 0 Else Portb.1 = 1 End If Gi1 = Gi1 - 1 If Gi1 = 255 Then Gi1 = 0 If Bi1 > 0 Then Portb.2 = 0 Else Portb.2 = 1 End If Bi1 = Bi1 - 1 If Bi1 = 255 Then Bi1 = 0 Return