Go Down

Topic: how do I know if a output is high (Read 286 times) previous topic - next topic

Sanddune600

I want to start a counter in my project based on if a output is high here is what I tried first with no luck I searched but didnt find anything am I missing something or is this not possable

if (outputpin == HIGH) counter++;

I aslo tried

if (digitalread (outputpin == HIGH)) counter++;

guix

Hello, that should be:
Code: [Select]

if ( digitalread( outputpin ) == HIGH ) counter++;


Or, since HIGH is like "true", simply this:
Code: [Select]

if ( digitalread( outputpin ) ) counter++;

groundfungus

in your setup() is pinMode(outputpin, OUTPUT);
and to read it, if(digitalRead(outputpin)==HIGH);

note case in pinMode() and digitiaRead()

guix

Just wondering, if it's an output then you probably use digitalWrite( outputpin, state ) somewhere, so you already know the current value of the output.

Sanddune600

yes its an output I actual dont have a PinMode selected it is working as an output so I didnt notice it because the outputs are working I will try it with it included

I just realized that counter was probably the wrong word to use I am wanting to use it as a timer to shut off the output after 5minutes

Go Up