RegisterSearchFAQMemberlistUsergroupsLog in
Reply to topic Page 1 of 1
Flashing Warning Light
Author Message
Reply with quote
Post Flashing Warning Light 
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

View user's profile Send private message
Reply with quote
Post  
Hi, you'd have to have a separate counter that increments on every onTick(). A simple way is, if that value is odd, then make sure the output is off.

There are some shift light examples in our example library that implement something like this.

Let us know what you come up with!


_________________
Brent Picasso
Founder, Autosport Labs
Facebook | Twitter
View user's profile Send private message Send e-mail
Reply with quote
Post  
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

View user's profile Send private message
Reply with quote
Post  
Nice, I'm going to try and implement that this weekend. I like the simple "on" along with "flashing" combo.

View user's profile Send private message
Reply with quote
Post  
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.

View user's profile Send private message
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum