Intrygujący tęczowy kryształ

To forum jest dla wszystkich pasjonatów mikrokontrolerów AVR Atmela. Wymiana doświadczeń i pomoc dla początkujących w pisaniu programów zarówno w C, Asemblerze jak i BASCOM. Zapraszam znawców tematu, aby pomogli wszystkim początkującym!
ODPOWIEDZ
Awatar użytkownika
seweryn
Użytkownik
Posty: 147
Rejestracja: 08 gru 2005, 20:04
Lokalizacja: Praszka
Kontakt:

Intrygujący tęczowy kryształ

Post autor: seweryn » 30 lip 2006, 8:08

Zbudowałem układ podobny do projektu w Edw 11/04 tylko że dałem tam 90s2313 i do sterowania diod użyłem tranzystorów. Napisałem program w bascom i jest prawie wszystko ok. Jedyny problem to to że nieraz przy przejściu kolorów szczególnie gdy dwa na raz świecą to widać jakieś mrógnięcia jednego z kolorów. Wydaje mi się że jest to wina programu. Efekt jest niesamowity tylko te mrógnięcia!!!

Config Portb = Output
Portb = 255
Dim R As Byte , G As Byte , B As Byte , Licznik As Byte
Dim A As Byte , C As Byte , D As Integer , E As Byte
Config Timer0 = Timer , Prescale = 1
Enable Timer0
Enable Interrupts
On Timer0 Petla
G = 255
R = 255 'wszystko zgaszone
B = 255

Do
A = 254 : C = 10 : D = -1 : E = 5 : Gosub Red
A = 254 : C = 10 : D = -1 : E = 5 : Gosub Blu
A = 10 : C = 254 : D = 1 : E = 5 : Gosub Red
A = 254 : C = 10 : D = -1 : E = 5 : Gosub Gre
A = 10 : C = 254 : D = 1 : E = 5 : Gosub Blu
A = 254 : C = 10 : D = -1 : E = 5 : Gosub Red
A = 254 : C = 10 : D = -1 : E = 5 : Gosub Blu
A = 10 : C = 254 : D = 1 : E = 5 : Gosub Red
A = 10 : C = 254 : D = 1 : E = 5 : Gosub Gre
A = 10 : C = 254 : D = 1 : E = 5 : Gosub Blu
A = 254 : C = 10 : D = -1 : E = 5 : Gosub Gre
A = 254 : C = 10 : D = -1 : E = 5 : Gosub Red
A = 10 : C = 254 : D = 1 : E = 5 : Gosub Red
A = 10 : C = 254 : D = 1 : E = 5 : Gosub Gre
Loop

Red:
For R = A To C Step D
Waitms E
Next R
Return

Gre:
For G = A To C Step D
Waitms E
Next G
Return

Blu:
For B = A To C Step D
Waitms E
Next B
Return

Petla:
If Licznik = 0 Then Portb = 0
If Licznik = R Then Portb.0 = 1 'PWM
If Licznik = G Then Portb.1 = 1
If Licznik = B Then Portb.2 = 1
Incr Licznik
Return

ODPOWIEDZ