MICRO - DICE
PROGRAM - HOW IT WORKS
THE PROGRAM
program LED_Dice_decay
dim portb_bit as byte
dim porta_bit as
byte
'Declare variables
dim counter as
integer
main:
TRISB =
%00000001 ' Configure pins of PORTB as output, but pin zero as
input
TRISA = %11111111
PORTB =
%11111110
'Turn LED's off
' PORTA =
%00000000
counter = 1
eloop:
'Start of loop
portb_bit =
PORTB.0
'Get button status
if portb_bit = 1
then 'Button press
counter = counter + 1
end if
porta_bit =
PORTA.6
'Get fast / slow status
if porta_bit = 1
then
'slow mode
delay_ms(300)
end if
if counter = 7
then
'error handle
counter = 1
end if
select case
counter 'Turn appropriate LED's on
case 1
PORTB =
%11101110
case 2
PORTB =
%11010110
' 0 is ON
case 3
PORTB = %11000110
case
4
PORTB =
%01010100
' 1 is OFF
case 5
PORTB = %01000100
case
6
PORTB = %00010000
end select
goto
eloop
' Stay in loop
end.
MORE INFORMATION
TROUBLESHOOTING