You are on page 1of 2

ejemplo5.

mbas

14/11/2011 12:18:24

1: 2: 3: 4: 5:

6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: symbol D0=PORTB.0 'Nos sirva para dar nuestros porpios nonbres a los regist tros 23: symbol D1=PORTB.1 24: symbol DISPLAY=PORTD 25: ' Declarations section 26: dim i, oldstate as byte 'declaracion de varaibles 27: 28: const NUMEROS as byte[10] = (191,134,219,207,230,237,253,135,255,239) 'valores del DI ISPLAY para que visualice los datos 29: sub procedure setup 'subrutina de configuracion. 30: PORTD=0 31: TRISB=0 32: TRISC=255 33: TRISD=0 34: i=0 35: D0=1 36: D1=1 37: end sub 38: 39: sub procedure incremente 'sub rutina de incremento 40: i=i+1 41: if i>9 then 'no incremente si es 9 42: i=9 43: end if 44: end sub 45: sub procedure decremente 'sub rutina de decremento 46: if i>0 then 'no decremente si es 0 47: i=i-1 48: end if 49: end sub 50: sub procedure ver 'sub rutina de visualizacion 51: DISPLAY=NUMEROS[i] 'acceso al vertor mediante el puntero i 52: end sub 53: 54: main:

program ejemplo5 ' * ' * Nombre ' Ejemplo 5 ' Basado en el Ejemplo 4 utilizamos el incremento y decremento mediante pulsantes y utilizando sub procedimientos. ' * Autor: ' Ing. Pablo Rodas Msc -UETS' * Fecha: ' 14/11/2011: ' ' * Descripcion ' Manejo de vectores y de la funcion SYMBOL ' ' * Configuracion ' MCU: P16F887 ' Archivo Simulacion PROTEUS: Entrenador ' Oscillador: HS, 4.0000 MHz ' ' * NOTAS '

1/2

mikroBasic Pro for PIC by mikroElektronika

ejemplo5.mbas

14/11/2011 12:18:24

55: ' Main program 56: setup 57: 58: while true 59: if Button(PORTC, 0, 1, 0) then 'pulsante activado al soltarse 60: oldstate=255 61: end if 62: if oldstate and Button(PORTC, 0, 1, 1) then 63: incremente 64: oldstate=0 65: end if 66: 67: 68: if Button(PORTC, 1, 100, 0) then 'pusante activado al pulsarse 69: decremente 70: end if 71: ver 72: 73: 74: wend 75: 76: end.

2/2

mikroBasic Pro for PIC by mikroElektronika

You might also like