|
CLASS DOCUMENTS
REPORTS & ASSIGNMENTS
CLASS CONTENT
USING THIS SITE
registered authors login here You are: (logout) For more on PMWiki, see pmwiki.org |
Solarpicoriginal by Tom Igoe, modifications by Marta Lwin Reads an Analog input. Used in this case to read a solar cell as a light meter.
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 20 ' Set sampling time in uS
PeakValue var word
SensorValue var word
LastSensorValue var word
Threshold var word
Noise var word
' serial pins and data reate:
tx var portc.6
rx var portc.7
n9600 con 16468
Threshold = 50 ' set your own value based on your sensors
PeakValue = 0 ' initialize peakValue
noise = 5 ' set a noise value based on your particular sensor
' Set PORTA to all input
TRISA = %11111111
' Set up ADCON1
ADCON1 = %10000010
Main:
' read sensor on pin RA0:
ADCin 0, sensorValue
serout2 tx, n9600, [sensorValue]
pause 100
Goto main
|