Electronic Interlock

Hello,

I have tried using a while loop to create an electronic interlock, so that when i press a button on the the webserver, it will prevent a light being switched on. This light will be controlled via another button but wont be able to function until the interlock is disabled.

So essentially i want the relay controlling the light to be set to LOW while the 'isolate' button is HIGH, and i want it to stay LOW until the 'isolate' is set to LOW via another button press. This will then allow separate buttons to switch the relay HIGH and LOW.

I have attached the code.

Any advice would be appreciated.

Thank you

ProjectInterlock.ino (8.25 KB)

You mean something like:

  if (digitalRead (isolate))
    light_on = true ;
  else if (digitalRead (de_isolate))
    light_on = false ;
  digitalWrite (relay, light_on) ;

??

Suggestion... Post your code don't attach. People are less interested in viewing attached code.

I would :

  1. assign a Pin# to the interlock button
  2. create a bool variable to prevent the light coming on
  3. code the interlock button presses to toggle the variable between true and false.

Thank you for the information and code MarkT and aisc. I will try some variations of your code tomorrow.

aisc:
Suggestion... Post your code don't attach. People are less interested in viewing attached code.

I tried unfortunately it was over the character limit

Yep i tried the post again through preview and it worked, must have used the code brackets incorrectly, apologies.

Thank you for the help, I have no got the interlock working!

AreJ:
Thank you for the help, I have no got the interlock working!

I'm sorry to hear that.

if (digitalRead(HighLevelSwitch))                // reads HighFloatFail

          {
            client.print("<td> fail </td>");              // prints to webserver that float has failed
          }

          else

          {
            client.print("<td> functional </td>");        // prints to webserver that float is functional
          }

How do u expect this to work without any comparison?
You are reading the switch, but you still need to compare it to some value to determine it has failed.
Something like this....

if (digitalRead(HighLevelSwitch) == 1) ? client.print("<td> fail </td>") : client.print("<td> functional </td>");

Delta_G:

if (digitalRead(HighLevelSwitch))

This line works fine. Without the comparison you are just testing that the value returned from digitalRead is not 0. Some argue that this is abuse of the API. Let's not hash that out again. But from a "does it work" standpoint this is fine.

I think Mr. Gammon was the one who had the best argument here. If you feel you need to compare then why not all the way out?

if ((digitalRead(HighLevelSwitch) == HIGH) == true)

Noted. Something I need to remember.