Pages: [1]   Go Down
Author Topic: how do I know if a output is high  (Read 275 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 43
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

France
Offline Offline
Edison Member
*
Karma: 38
Posts: 1012
Scientia potentia est.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, that should be:
Code:
if ( digitalread( outputpin ) == HIGH ) counter++;

Or, since HIGH is like "true", simply this:
Code:
if ( digitalread( outputpin ) ) counter++;
Logged

BCC AZ USA
Offline Offline
Edison Member
*
Karma: 38
Posts: 1335
It gets hot so it must be working
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

note case in pinMode() and digitiaRead()
Logged

France
Offline Offline
Edison Member
*
Karma: 38
Posts: 1012
Scientia potentia est.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 43
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: