How to make Led blinking

Forum Home Forums Development and Integration How to make Led blinking

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #9710
    dp_palai
    Participant

    Hi, 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 2 years, 4 months ago by dp_palai.
    #9712
    JW
    Participant

    the 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; on

    then you setup an other channel for led, e.g. 1002,
    set formula
    Val(1001)==0?0:Val(1001)+Second(DateTime.Now)%2

    then the value will toggle between 1 and 2 every second when the device is on, and remain 0 when the device is off.

    #9718
    Mikhail
    Moderator

    Hi,
    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 2 years, 4 months ago by Mikhail.
    #9722
    dp_palai
    Participant

    Thanks, Mikhail for a prompt response.

    #9726
    dp_palai
    Participant

    Thanks a lot, JW!. You are amazing.

    #9741
    Caramel Macchiato
    Participant

    I tried it, It’s cannot change per second??

    #9745
    Mikhail
    Moderator

    Could you specify your question?

    #9746
    dp_palai
    Participant

    @caramel-macchiato It worked for me. So you must be missing some steps while configuring all required areas.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.