global [a b c d bits y] to init write portb-ddr 0 write portb 0 setbit 4 portb setbits 0 sety 0 end to clock setbit 6 portb repeat 20 [no-op] clearbit 6 portb end to latch setbit 5 portb repeat 20 [no-op] clearbit 5 portb end to on setbit 7 portb ;repeat 100 [no-op] end to off ;repeat 100 [no-op] clearbit 7 portb end to justone :n setn :n - 1 blank on clock repeat n [off clock] latch clearbit 4 portb flicker end to any-thirty setbits random % 2 ;randomly select 1 or 0 only ;depending on the randomly selected bits, the LogoChip ;will send 1's or 0's until there are 30 1's. ;it will then display/light the LEDs if (bits = 1) [on clock sety y + 1] if (bits = 0) [off clock] if (y > 30) [ sety 0 latch flicker blank ] any-thirty end ;Flicker and fade out effect ;B4 controls the output enable of the LED drivers to flicker repeat 5 [ clearbit 4 portb mwait 1 setbit 4 portb mwait 10 ] repeat 10 [ clearbit 4 portb mwait 10 setbit 4 portb mwait 20 ] repeat 6 [ clearbit 4 portb mwait 5 setbit 4 portb mwait 30 ] repeat 5 [ clearbit 4 portb mwait 1 setbit 4 portb mwait 10 ] end to blank repeat 48 [off clock] latch end ;Lights up all LEDs - useful for checking which ones are out to all on repeat 50 [clock mwait 10] latch clearbit 4 portb end to powerup init all end to startup init loop [any-thirty] end