You are on page 1of 2

Ejemplo13.

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:

1/12/2012 7:49:46 AM

program Ejemplo13
' *
' * Nombre del Ejemplo
' Ejemplpo 12
' * Autor:
'
Ing. Pablo Rodas -CTS' * Fecha:
'
20120109:
'
' * Descripcion
'
Conversor AD con dos entradas analogicas
'
' * Configuracion
'
MCU:
P16F887
'
Archivo Simulacion PROTEUS:
Entrenador
'
Oscillador:
HS, 4.0000 MHz
'
' * NOTAS
' *
' SECCION DE DECLARACIONES DE SIMBOLOS
'*****************************************************************************
' SECCION DE DECLARACIONES DE VARIABLES
'**************************************************
dim LCD_RS as sbit at RB2_bit
LCD_EN as sbit at RB3_bit
LCD_D4 as sbit at RB4_bit
LCD_D5 as sbit at RB5_bit
LCD_D6 as sbit at RB6_bit
LCD_D7 as sbit at RB7_bit
LCD_RS_Direction
LCD_EN_Direction
LCD_D4_Direction
LCD_D5_Direction
LCD_D6_Direction
LCD_D7_Direction
dim dato as word
txt as string[12]
Dim valor as word

as
as
as
as
as
as

main:
'
Main program
ANSEL = 0x06
ANSELH = 0
C1ON_bit = 0
C2ON_bit = 0
TRISA = 0xFF
LCD_INIT()
ADC_Init()
while (TRUE)
valor = ADC_Read(2)
wordtostr(valor,txt)
lcd_out(2,1,txt)

sbit
sbit
sbit
sbit
sbit
sbit

at
at
at
at
at
at

TRISB2_bit
TRISB3_bit
TRISB4_bit
TRISB5_bit
TRISB6_bit
TRISB7_bit

' Configure AN2 y AN1 pin as analog


' Configure other AN pins as digital I/O
' Disable comparators
' PORTA is input

' Get 10-bit results of AD conversion

1/2

mikroBasic Pro for PIC by mikroElektronika

Ejemplo13.mbas

58:
delay_ms(100)
59: valor = ADC_Read(1)
60:
wordtostr(valor,txt)
61:
lcd_out(1,1,txt)
62:
delay_ms(100)
63:
64: wend
65: end.

1/12/2012 7:49:46 AM

' Get 10-bit results of AD conversion

2/2

mikroBasic Pro for PIC by mikroElektronika

You might also like