Preface: noob here when it comes to scripting.
I've seen the wiki example script for a warning light for say temperature, low pressure, etc.- is it possible to have this light flash, and what would that code look like? Thanks!
Standard:
--Analog 0 is engine temp, in degrees F
--Analog 1 is oil pressure, in PSI
function onTick()
if getAnalog(0) > 212 or getAnalog(1) < 10 then
setGpio(0, 1)
else
setGpio(0, 0)
end
end
Flashing Warning Light
Here's a script to make a light wired to GPIO(0) come on at a certain point and flash at a different point (like water temp). thanks to David Alexander.
--point at which light comes on
local waterOn = 195
--point at which light flashes
local waterBlink = 200
local timer = 1
function warningLed()
if getAnalog(0) > waterOn then
setGpio(1, 1)
else
setGpio(1, 0)
end
if getAnalog(0) > waterBlink then
if timer == 1 then
setGpio(1, 0)
timer = 2
else timer = 1
end
end
end
function onTick()
warningLed()
end
--point at which light comes on
local waterOn = 195
--point at which light flashes
local waterBlink = 200
local timer = 1
function warningLed()
if getAnalog(0) > waterOn then
setGpio(1, 1)
else
setGpio(1, 0)
end
if getAnalog(0) > waterBlink then
if timer == 1 then
setGpio(1, 0)
timer = 2
else timer = 1
end
end
end
function onTick()
warningLed()
end
Just a thought. I've always used a redundant water pressure sender to a lite, completely independent of the digital gauges/sender. in dirt racing we are usually blowing hoses or poking holes in the radiator so you'll see a loss of pressure long before any rise in temp. sometimes you wont even see a rise in temp since a typical water temp gauge cant measure air temp (i.e no water in block). just food for thought.