Shutter Interlocking

Discussion in 'Pascal Logic Code Examples' started by Ashley, Oct 31, 2018.

  1. Ashley

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    The following code can be used to interlock shutters with window/door open sensors.
    The logic simple tests each interlock ga each second, and if it is set (i.e window/door open) then the shutter will be opened

    Code:
    // Global Section
    //
    // Set the size of the array to the number of shutter interlocks
    shutters: array[0..25] of char;
    shutterInterlocks: array[0..25] of char;
    i: integer; // For counter
    shutter: integer; // Temp shutter ga
    
    // Initialization section
    //
    // The shutter array lists all the shutter gs'a that require interlocking
    // The ShutterInterlocks  array lists the ga of the corresponding interlock
    // Note: Character arrays are used here because they can be initialized in a single line.
    // If the shutter has more than one interlock, just repeat the shutter number with additional interlocks
    // Whenever the interlock is TRUE (i.e. Window/Door open), the shutter will be forced open
    //
    // Edits these to suit your installation
    //
    shutters :=              #150#150#151#152#152#154#155#156#158#159#159#161#163#164#165#166#167#168#168#169#170;
    shutterInterlocks := #054#055#053#046#047#048#042#041#058#056#057#061#038#031#032#043#049#059#060#050#044;
    
    // Module 'Shutters'
    //
    // Shutter interlocks ensures blind is up if window/door is open
    //
    for i := 1 to length(shutters) do
    begin
       if GetLightingLevel(ord(shutterInterlocks[i]) then 
       begin
          shutter := ord(shutters[i]);
          if GetLightingLevel(shutter) <> 255 then
          SetLightingLevel(shutter, 100%, "0s");
       end;
    end;
    delay(1);
    
    
     
    Ashley, Oct 31, 2018
    #1
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.