Code.Leds History
Hide minor edits - Show changes to output
Added lines 1-5:
By [[~jk1667|Jen Kirchherr]]
This simple PicBasic Pro code works with Figaro Gas Sensors. It will light three LEDs when the level of air contaminants reaches a point when the serial out of the sensor exceeds 400, (about halfway through the sensor's range) in addition to giving three serial out values for three of these sensors.
This simple PicBasic Pro code works with Figaro Gas Sensors. It will light three LEDs when the level of air contaminants reaches a point when the serial out of the sensor exceeds 400, (about halfway through the sensor's range) in addition to giving three serial out values for three of these sensors.
Changed lines 8-11 from:
[@
to:
[@
DEFINE ADC_BITS 10
Added lines 3-5:
This simple PicBasic Pro code works with Figaro Gas Sensors. It will light three LEDs when the level of air contaminants reaches a point when the serial out of the sensor exceeds 400, (about halfway through the sensor's range) in addition to giving three serial out values for three of these sensors.
Changed lines 1-2 from:
to:
Back to [[Reports.Gas Sensors | Gas Sensors]]
Added lines 1-53:
[@DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 20
sensorValue0 var word
sensorValue1 var word
sensorValue2 var word
tx var portc.6
rx var portc.7
n9600 con 16468
TRISA = %11111111
ADCON1 = %10000010
output portb.7
output portb.6
output portb.5
Pause 10000
Main:
ADCin 0, sensorValue0
ADCin 1, sensorValue1
ADCin 2, sensorValue2
if sensorValue0 > 400 then
high portb.7
else
low portb.7
endif
if sensorValue1 > 400 then
high portb.6
else
low portb.6
endif
if sensorValue2 > 400 then
high portb.5
else
low portb.5
endif
serout2 PORTC.6, 16468, [" TGS 2620 ", DEC sensorValue0]
serout2 PORTC.6, 16468, [" TGS 2602 ", DEC sensorValue1]
serout2 PORTC.6, 16468, [" TGS 2600 ", DEC sensorValue2, 13, 10]
'serout2 tx, n9600, [sensorValue0/4] Use this to put these values into processing
'serout2 tx, n9600, [sensorValue1/4]
'serout2 tx, n9600, [sensorValue2/4]
pause 50
Goto main @]
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 20
sensorValue0 var word
sensorValue1 var word
sensorValue2 var word
tx var portc.6
rx var portc.7
n9600 con 16468
TRISA = %11111111
ADCON1 = %10000010
output portb.7
output portb.6
output portb.5
Pause 10000
Main:
ADCin 0, sensorValue0
ADCin 1, sensorValue1
ADCin 2, sensorValue2
if sensorValue0 > 400 then
high portb.7
else
low portb.7
endif
if sensorValue1 > 400 then
high portb.6
else
low portb.6
endif
if sensorValue2 > 400 then
high portb.5
else
low portb.5
endif
serout2 PORTC.6, 16468, [" TGS 2620 ", DEC sensorValue0]
serout2 PORTC.6, 16468, [" TGS 2602 ", DEC sensorValue1]
serout2 PORTC.6, 16468, [" TGS 2600 ", DEC sensorValue2, 13, 10]
'serout2 tx, n9600, [sensorValue0/4] Use this to put these values into processing
'serout2 tx, n9600, [sensorValue1/4]
'serout2 tx, n9600, [sensorValue2/4]
pause 50
Goto main @]