Sei sulla pagina 1di 2

jasr.

mbas

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:

01/10/2011 05:59:17 p.m.

program jasr
' Matriz portd_array tiene 4 miembros de tipo word
a, b as byte
dim
dim x, n as word
portb_array as word[4]
sub function mask (dim cont as word) as word
select case cont
case 0 result = %000111111
case 1 result = %000011000
case 2 result = %001110110
case 3 result = %001111100
case 4 result = %001011001
case 5 result = %001101101
case 6 result = %001001111
case 7 result = %000111000
case 8 result = %001111111
case 9 result = %001111001
end select
end sub
Tone()
sub procedure
Sound_Play(659, 250) ' Frecuencia = 659Hz, duracin = 250ms
end sub
sub procedure interrupt ' inicio de rutina de interrudcion
porta = 0 'apagar todos los visualisadores
portb = portb_array [b]
porta= a
a = a << 1
if (a > 8)then
a = 1
end if
inc(b) ' incrementar portb_index
if (b > 3)then
b = 0 ' enciende el primer y apaga el cuarto visualizador
end if
tmr0 = 0 ' reinicia el valor del timero
t0if_bit=0 ' borra la varera de interuccion del timer0
end sub
' final de la interuccion
main:
'
Main program
option_reg= $80
' configuracion del tiemer0 (funciona como temporizador
x=0
b= 0
a=1
tmr0=0
intcon = $A0
'habilita INTERUCCION CON LOS BITS GIE Y TOIE
porta=0
trisa= %10000
portb=0
trisb= 0
n = 0000
while true
miro: if porta.4 =0then
delay_ms(70)
if porta.4 =1 then

1/2

mikroBasic Pro for PIC by mikroElektronika

jasr.mbas

58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:

01/10/2011 05:59:17 p.m.

x = (n/1000)
portb_array[3] = mask(x)
x=(n/100) mod 10
portb_array[2] = mask(x)
x=(n/10) mod 10
portb_array[1] = mask(x)
x= (n/1) mod 10
portb_array[0]= mask(x)
inc(n)
end if
if (n=2) then
portb.7=1
end if
if (n = 9999) then
n= 0000
end if
end if
goto miro
wend
end.

2/2

mikroBasic Pro for PIC by mikroElektronika

Potrebbero piacerti anche