`picaxe 08m temp and rpm warning
high 2 'set warning LED on for test
Pause 2500
low 2 'turn off warning LED
symbol lm0 = w0
symbol lm1 = w1
symbol ADVal = w4
main:
'''''''''TEMPERATURES SECTION''''''''''
if w2<w1 then
w2=w1
endif
if w3<w0 then
w3=w0
endif
lm0 = 0 'set temp sender value to 0
lm1 = 0 'set rpm to 0
'READ temperature on ADC1
w5 = 0
For w5 = 1 to 2 'read values and send average value to lm0
ReadADC 1 , ADVal
lm0 = lm0 + ADVal
Next
ADVal = lm0 / 2 'average readings
lm0 = ADVal * 4 ' math to convert the output into degrees
adval = 0 'reset adval to use later
'READ revolutions on ADC4
w6 = 0
For w6 = 1 to 2
ReadADC 4 , ADVal
lm1 = lm1 + ADVal
Next
ADVal = lm1 / 2 'average
lm1 = ADVal * 400
adval = 0
init: pause 500
SerOut 0, n2400, (254,128,"CHT",254,132,#w0,"" ) 'pin7 output to LCD, 2400baud.
pause 10
serout 0, n2400, (254,192,"RPM",254,196,#w1,"")
pause 10
if pin3 = 1 then readmax
if lm0 > 250 then goto lighton 'if cylinder head temperature is greater than 250 then light the warning LED, otherwise...
if lm1 > 15000 then goto lighton 'if rpm is greater than 300 then light that warning LED.
if w0 < 225 then goto lightoff
goto main
READMAX:
serout 0,n2400,(254,128,"MAX TEMP",#w3,"")
pause 10
serout 0,n2400,(254,192,"MAX RPM",#w2,"")
pause 10
if pin4 = 1 then readmax
lighton:
high 2
goto main
lightoff:
low 2
goto main