Tuesday, February 28, 2006

w_3 variables & analog input_code from Michael

'****************************************************************
'* Name : UNTITLED.BAS *
'* Author : Mike Reger *
'* Notice : Copyright (c) 2006 Mikro In Control *
'* : All Rights Reserved *
'* Date : 2/28/2006 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
DEFINE OSC 4

DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS

ADCvar VAR WORD ' Create variable to store result

TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify result
Pause 500 ' Wait .5 second

main:
ADCIN 0, ADCvar ' Read channel 0 to adval
serout2 PORTC.6, 16468, [DEC ADCvar, 13, 10] ' print it to serial out,
' with linefeed and carriage return (10, 13)
GoTo main ' Do it forever

0 Comments:

Post a Comment

<< Home