Forum Home › Forums › Development and Integration › How to make Led blinking
- This topic has 7 replies, 4 voices, and was last updated 3 years, 11 months ago by
dp_palai.
-
AuthorPosts
-
November 29, 2021 at 8:55 am #9710
dp_palai
ParticipantHi, I have a requirement where I am using a Led to show the device is switched ON. Led remains ON as long as the device is running. I configure a Led for it. But my additional requirement is that Led should blink when it remains ON. I am struggling to get how to do that. Please help. Thanks in advance.
-
This topic was modified 3 years, 12 months ago by
dp_palai.
November 29, 2021 at 9:42 am #9712JW
Participantthe trick is set two “ON” states for your led, and toggle between them.
set a led with condition
0; 1; 2 for silver; light green; green.assume you have multiple led, they should blink at the same time.
step 1, defind a function in formula, which is the value of second of current time.
———
double Second(DateTime dt){
double en_dt = EncodeDate(dt);
double s = Math.Truncate(en_dt * 24 * 60 * 60) % 60;
return s;
}
——–you can have 1 input channel for device status, e.g. Cnl 1001
0; 1 for off; onthen you setup an other channel for led, e.g. 1002,
set formula
Val(1001)==0?0:Val(1001)+Second(DateTime.Now)%2then the value will toggle between 1 and 2 every second when the device is on, and remain 0 when the device is off.
November 29, 2021 at 10:01 am #9718
MikhailModeratorHi,
In addition to the previous answer.
Color also can be taken from channel status.
Channel value 1 means that device is running.
Custom channel statuses may change led color.
So channel formula could be Cnl; (Second(DateTime.UtcNow) % 2) > 0 ? 101 : 102
where 101 and 102 your custom statuses specified in the Event types table.
And in the Scheme editor specify the Status color.-
This reply was modified 3 years, 12 months ago by
Mikhail.
November 30, 2021 at 5:47 am #9722dp_palai
ParticipantThanks, Mikhail for a prompt response.
November 30, 2021 at 11:38 am #9726dp_palai
ParticipantThanks a lot, JW!. You are amazing.
December 8, 2021 at 2:07 am #9741
Caramel MacchiatoParticipantI tried it, It’s cannot change per second??
December 8, 2021 at 12:18 pm #9745
MikhailModeratorCould you specify your question?
December 8, 2021 at 12:25 pm #9746dp_palai
Participant@caramel-macchiato It worked for me. So you must be missing some steps while configuring all required areas.
-
This topic was modified 3 years, 12 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.