Just starting ... so of course thousands of questions.
In my sketch, all my buttons and switches are set up with input_pullup.
So, its false so to speak when activated.
I would like to be able to say ..
button_is_pressed = digitalread(button_pin)
if (button_is_pressed)
blah blah
but the digitalread actually returns false when the button is pressed. (as it should)
Here's my loop code
{
Request_Is_Received = digitalRead(Request_Button);
if (Request_Is_Received == LOW) // would like to not have to do this
{
if (Gate_A_Is_Closed() && Gate_B_Is_Closed()) // gates are closed
{
Open_The_Gates();
}
else // gates are not closed so they are open or stuck trying
{
Close_The_Gates();
}
}
}
Thanks Dev .. that's exactly what I was looking for, that will save me a bunch of work arounds.
Button_Is_Pressed = !digitalRead(Button_Pin)
I did know about the !,
I actually do spend a LOT of time in the reference. It honestly seems that the questions I have are not
answered ((in the reference) (or I can find it .. possible))
This is a perfect example. Actually go look at the info on ! 1 little example and 2 sentences.
But thanks TO this forum I understand now that you can even boolean a function. HOW COOL.
No, you're not "booleaning the function". You are using the return value of the function in an expression.
You can do much cooler things with functions. Look for a C++ reference online. Almost all of them will explain the standard libraries which are available on the Arduino but never get mentioned in the Arduino reference.