Some neat stuff I forgot that I found several years ago on Charlie-plexing.
Code:clear define osc4 cmcon0=7 ansel=0 adcon0 = 0 @ device mclr_off @ device wdt_off @ device bod_off @ device cpd_off @ device protect_off led var byte ledstates var byte trisstate var byte delay var word noghost var byte gpnoghost var byte noghost= %111111 delay= 1500 starthere: gpio.3 = 0 if gpio.3 = 1 then goto main endif goto starthere main: for led = 1 to 6 select case led case 0 : ledstates =%001 : trisstate =%100 case 1 : ledstates =%010 : trisstate =%100 case 2 : ledstates =%001 : trisstate =%010 case 3 : ledstates =%100 : trisstate =%010 case 4 : ledstates =%100 : trisstate =%010 case 5 : ledstates =%010 : trisstate =%001 case 6 : ledstates =%100 : trisstate =%001 end select trisio = noghost gpio = ( gpio & %111000) | ledstates trisio = (trisio & %111000) | trisstate pause delay next led for led = 1 to 5 select case led case 1 : ledstates =%000001: trisstate =%101110 case 2 : ledstates =%011000: trisstate =%101110 case 3 : ledstates =%000010: trisstate =%101101 case 4 : ledstates =%010000: trisstate =%101101 case 5 : ledstates =%000010: trisstate =%011101 end select trisio = noghost gpio = ( gpio & %111000) | ledstates trisio = (trisio & %111000) | trisstate pause delay next led trisio=noghost gpio=gpnoghost goto starthere end
Editted to add some colour, original was black on light gray background.
I wish I could give a link and credit, but I can't find anything on google for this now (been looking for over an hour).
Robert




Bookmarks