'****************************************************************
'* Name : adc con led y LCD para verlo biennnnn *
'* Author : carptroya *
'* Notice : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 03/05/2011 *
'* Version : 2.0 *
'* Notes : *
'* : *
'****************************************************************
Device=16F876
Xtal 4
LCD_Type = 0 ' LCD alfanumerica tipica
LCD_DTPin = PORTC.4 ' datos PORTB.4,5,6,7
LCD_RSPin = PORTC.2 ' LCD RS pin
LCD_ENPin = PORTC.3 ' LCD EN pin
LCD_Interface = 4 ' 4-bit LCD
LCD_Lines = 2 ' 2-Line LCD
Declare Adin_Res 8 'resultado de 8-bit
Declare Adin_Tad FRC 'OSC interno elegido
Declare Adin_Stime 100
TRISA =%00000001 ' poner el ano como entrada analogica
TRISB =%00000000 'poner el puerto como salida
TRISC =%00000000 'poner el puerto como salida
ADCON1.7 =0 ''sin justificacion un solo registro
Dim dato As Byte 'crear variable con valor byte =255
PORTB=0 'poner a cero el puerto completo
DelayMS 100 'retardo
'
'
'
' comienza el programa
'
'
inicio:
dato =ADIn 0 'guardar el valor digital obtenido en la conversion en el registro dato
DelayUS 3
PORTB=dato 'el puerto b toma el valor del registro dato
Print At 2,1," dato decm ",Dec3 dato
Print At 1,1," binario ", Bin dato
PORTB =0
GoTo inicio