how can i set so that when pin 28 is high, something has to happen ? if (28 == HIGH)
Look at the digital examples that ship with the IDE.
if (digitalRead(28) == HIGH) {
you mean something like
if (digitialread(sdofjnsodvjb) == higherThenHigh)
{
goLowerThenHighestHigh();
}
thank you very much for both answers: D
I still want to ask how can I take more buttons into one if if (digitalRead[4,5,6,7] == HIGH)
You have to do that sequentially, unless you can arrange for all the pins to be on the same port,up to a maximum of eight inputs
if (digitalRead(1) == HIGH && digitalRead(2) == HIGH && digitalRead(3) == HIGH…
Thank you
This is a rare case where I often utilize white space. Some compilers enforce a maximum of 255 characters per line, in any case, it is easier to read:
if (digitalRead(1) == HIGH
&& digitalRead(2) == HIGH
&& digitalRead(3) == HIGH
&& digitalRead(4) == HIGH
{ ...
If you have a ridiculous number of pins, you can do it programmatically.
int result = LOW;
for (i = 0; i < numPins; i++) {
result &= digitalRead( pins[i] );
}
{coughs, politely}
Not seeing it... but at least this needs to be:
int pins[] = {1, 2, 3, 4 };
int numPins = sizeof pins[] / sizeof pins[0];
int result = HIGH;
for (int i = 0; i < numPins; i++) {
result &= digitalRead( pins[i] );
}
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.