Variables and Analog Input


‘ PicBasic Pro program to display result of
‘ 10-bit A/D conversion through serial at 9600 baud
‘
‘ Connect analog input to channel-0 (RA0)
‘ Define ADCIN parameters
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
This week we were asked to wire the board so we could see some output shown on the PC Hyperdrive. I had the worst time soldering the serial connector (i ruined two!!), and it turned out the serial connector I was trying to solder wasn’t the ones with the little cups. I was using the serial connectors I got from my PComp pack and those were sooooo not solder friendly. Steven Jackson finally what was wrong and I finally got everything solder and programmed and done.
