Created Wed, 27 Aug 2014 18:43:34 +0000 by Francois_Swart
Wed, 27 Aug 2014 18:43:34 +0000
Hi All,
Relatively new to chipkit/arduino etc. In fact I have no Coding Skills.
I am trying to make a relatively simple device, used to indicate the status of alarm systems (Disarmed, Armed, or Alarm Condition)
The alarm systems have one output which works as follows; Constant low for disarmed, Constant High for armed and Pulsing if there is an alarm condition (pulse lengths vary from one manufacturer to another but range between 300ms high/300ms low and 1200ms high/1200ms low)
What I want to do is as follows:
convert the single input to three outputs (a rgb led)
led1 green is on only in the disarmed state (input low)and is off in the other 2 states led2 red is on only in the armed state (input high)and is off in the other 2 states led3 blue pulses when there is an alarm condition and is off in the other 2 states
Now my question: how do I sample (poll) the input say every 25ms and convert the input state to the various outputs?
if the input reads between 12 and 48 high values and then a low value led3 should pulse, anything above 48 high values would mean that led2 should be on, anything above 48 low reads would mean that led1 should be on.
can this be done? is this the most correct way?
if I use the PulseIn() function it would block any other code that I might have or want to add at a later stage.
Thanx for taking the time to read my post
Wed, 27 Aug 2014 20:12:47 +0000
Take a look at the BlinkWithoutDelay example program, and instead of blinking an LED read an input. Compare the input to HIGH or LOW, and add one to a counter. Every second, or however often you want, look at how many counts you have for high and low, light the right LED, and reset the counts.
Pretty simple really.