En esta pequeño programa utilizaremos un Display de 7 segmentos y con el programa realizaremos un arreglo en binario para mostrar los números en el display.
MikroBasic
program D7S
symbol leds = PORTA
dim numer as byte
dim numero as byte
SUB FUNCTION BCD(DIM num AS BYTE) AS BYTE
select case num
CASE 0 result = %00000000
CASE 1 result = %00000001
CASE 2 result = %00000010
CASE 3 result = %00000011
CASE 4 result = %00000100
CASE 5 result = %00000101
CASE 6 result = %00000110
CASE 7 result = %00000111
case 8 result = %00010000
case 9 result = %00010001
END SELECT 'case end
END SUB
main:
trisa = 0x00
leds = %0000
for numer = 0 to 9 step 1
leds = BCD(numer)
delay_ms(250)
next numer
for numero = 9 to 0 step -1
leds = BCD(numero)
delay_ms(250)
next numero
return
end.