Joshijc
Newbie level 3
- Joined
- Sep 14, 2010
- Messages
- 4
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Delhi, INDIA
- Activity points
- 1,319
I am relatively a new commer to PIC programming. So far I have been doing small programs in assembly language and now I want to lern PIC programming in C. Recently I have seen a program for electronic dice which appears to me neither in assy. language nor in C. I am reproducing it below as it is
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
First I wish to know in which language it is written. Secondly what the word 'dim' appearing in the biginning of the first three lines of the program. I will be extreamly greatfull to all those who will help me in this. Joshijc
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
First I wish to know in which language it is written. Secondly what the word 'dim' appearing in the biginning of the first three lines of the program. I will be extreamly greatfull to all those who will help me in this. Joshijc