DEFINE OSC 4

DEFINE ADC_BITS 8 'max of 10 bits here - use WORD; usu. 8 bits is enough
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEuS 20 'measures flow of electricity, 20 is standard
INPUT PORTA.0
output portd.0

ADCON1? = %00000010

adcVar var byte
RedLED? var portd.3
txPin var portc.6 'use portc.6 - it has hardware built in for receiving serial communication
x VAR byte
output RedLED? 'using this for blinky test

'always have a blinky for debugging purposes
FOR x = 0 to 2
HIGH RedLED?
PAUSE 200
LOW RedLED?
PAUSE 300
NEXT

main:

adcin 0,adcvar 'refers to where pot is; go to channel 0 and see what kind of electricity is flowing through here

if adcvar > 127 then
high portd.0
else
low portd.0
endif

SERout2? txPin, 16468, [dec adcvar, 13, 10] 'serial communication stuff, 16468 sets up speed of communication to 9600 baud
' DEC = decimal; 13 = carriage return; 10 = line feed --- these format adcVar for programs like ZTerm? for readability

goto main


Page last modified February 26, 2006, at 05:02 PM