You are on page 1of 4

program examen

dim piso as byte


dim boton as byte
dim temp as byte
sub procedure interrupt 'rutina de interrupcion
Delay_ms(20) 'eliminar rebote del boton
if(temp = 1) then
temp = 0
else
temp=1
end if
ClearBit(INTCON, INTF)
end sub
main:
ADCON1=0x06
TRISB=255
TRISC=0
TRISD=0
TRISA=0
PORTB=0
PORTD=0
PORTA=0
OPTION_REG=$40'flanco de subida para int en RB0
INTCON = $90'habilitar interrupcion
temp = 1
piso = 1
PORTA.0 = 0
PORTA.1 = 0
PORTD.0 = 1
while(true)
boton=PORTB
'************* INICIA BOTON PISO 3
if boton.5 = 1 then
PORTD = 0
if(piso = 1) then
while (boton.4 <> 1)
PORTA.0=1
PORTA.1=0
if(boton.2 = 1) then
piso = 1
PORTD.0 = 1
end if
if(boton.3 = 1)then
piso = 2
PORTD.1 = 1
end if
if(boton.4 =1)then
piso = 3
PORTA.0=0
PORTA.1=0

piso = 3
PORTD.2 = 1
break
end if
wend
PORTA.0=0
PORTA.1=0
piso = 3
PORTD.2 = 1
end if
if(piso = 2) then
while(boton.4 <> 1)
PORTA.0=1
PORTA.1=0
if(boton.2 = 1) then
piso = 1
PORTD.0 = 1
end if
if(boton.3 = 1) then
piso = 2
PORTD.1 = 1
end if
if(boton.4 =1) then
piso = 3
PORTA.0=0
PORTA.1=0
piso = 3
PORTD.2 = 1
break
end if
wend
PORTA.0=0
PORTA.1=0
piso = 3
PORTD.2 = 1
end if
if(piso = 3) then
PORTA.0=0
PORTA.1=0
piso = 3
PORTD.2=1
end if
end if
'**********TERMINA BOTON PISO 1
'***********INICIA BOTON PISO 2
if boton.6=1 then
PORTD = 0
if(piso = 1) then
while(boton.3 <> 1)
PORTA.0=1

PORTA.1=0
wend
PORTA.0=0
PORTA.1=0
piso = 2
PORTD.1 = 1
end if
if(piso = 2) then
PORTA.0=0
PORTA.1=0
piso = 2
PORTD.1=1
end if
if(piso = 3) then
while(boton.3 <> 1)
PORTA.0=0
PORTA.1=1
wend
PORTA.0=0
PORTA.1=0
piso = 2
PORTD.1 = 1
end if
end if
'**********TERMINA BOTON PISO 2
'***********INICIA BOTON PISO 3
if boton.7=1 then
PORTD = 0
if(piso = 1) then
while(boton.2 <> 1)
PORTA.0=0
PORTA.1=1
wend
PORTA.0=0
PORTA.1=0
piso = 1
PORTD.0 = 1
end if
if(piso = 2) then
while(boton.2 <> 1)
PORTA.0=0
PORTA.1=1
wend
PORTA.0=0
PORTA.1=0
piso = 1
PORTD.0 = 1
end if
if(piso = 3) then

PORTA.0 =0
PORTA.1 =0
piso = 1
PORTD.0 =1
end if
end if
'**********TERMINA BOTON PISO 3
wend
end.

You might also like