You are on page 1of 1

'****************************************************************

'* Name : UNTITLED.BAS *


'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 30/05/2014 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
INCLUDE "modedefs.bas" ;incluyen los modos de comunicacin
@ device XT_OSC ;cambia a oscilador XT
;Definimos parametros del conversor A/D
Define ADC_BITS 10 ;Numero bits del resultado=10
Define ADC_CLOCK 3 ;fuente del Reloj 3 (3=rc)
Define ADC_SAMPLEUS 50 ;tiempo de muestreo del ADC en useg
Resultado var word
dat var byte ;Historia de la conversion
TRISA = %11111111 ;PORTA configurado como entradas
ADCON1 = %10000000 ;PORTA analog y justificacion del resultado
;Programa Principal
inicio:
ADCIN 0, Resultado ;lee Ra0 y guarda en resultado
high portd.1
high portd.0
SEROUT portc.6,T2400,[#Resultado,"-"]
goto inicio:
MotorD:
SERIN portc.7,T2400,dat ;esperar el dato y guardarlo en dat
IF dat="C" THEN apagar ;si dat es una C empiece a contar

goto Inicio
apagar:
low portd.0

END

You might also like