5031pewp and logic

Discussion in 'C-Bus Wired Hardware' started by Nikita.Bagritsevich, Jun 8, 2012.

  1. Nikita.Bagritsevich

    Nikita.Bagritsevich

    Joined:
    May 8, 2012
    Messages:
    11
    Likes Received:
    0
    Location:
    Minsk
    Hi all,

    Why does not this code
    Code:
    lvl_old := lvl_new;
    lvl_new := GetCBusLevel("Floor5", "Lighting", "level");
    if ((lvl_old > 1%) and (lvl_new > 1%) and (lvl_old < 50%) and (lvl_new < 50%)) or
       ((lvl_old > 50%) and (lvl_new > 50%)) then
    begin
    counter := counter + 1;
    end
    else
    begin
    counter := 1;
    end;
    delay(3)
    lvl_new, lvl_old and counter - integer
    Outdoor Light Level Sensor - 5031pewp

    I want every three seconds recorded readings from the sensor, if the condition is satisfied
     
    Nikita.Bagritsevich, Jun 8, 2012
    #1
  2. Nikita.Bagritsevich

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    It looks like this logic code will increment the counter every three seconds while the level is between 1 and 50% or greater than 50%, but it is not clear why you would want to do that.

    Can you tell us what you are trying to do with this logic code?

    Can you tell us what you expect the code to do and what it is actually doing?
     
    Darren, Jun 9, 2012
    #2
  3. Nikita.Bagritsevich

    Nikita.Bagritsevich

    Joined:
    May 8, 2012
    Messages:
    11
    Likes Received:
    0
    Location:
    Minsk
    This logic needed to control the blinds. Thx for the answer, but I figured out what went wrong: it turns out the sensor transmits a number and not the percents. Because of this, the result is always false... in the comparison of counters and percents =)
     
    Last edited by a moderator: Jun 9, 2012
    Nikita.Bagritsevich, Jun 9, 2012
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.