Go Down

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


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++;


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++;


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

note case in pinMode() and digitiaRead()


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.


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

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131