Pages: [1]   Go Down
Author Topic: Writing port pins as output  (Read 255 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 3
Posts: 263
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've looked around but have not found if you can use this code

Code:
int powOn = 3;

void setup () {
pinMode(powOn, OUTPUT);
}
void loop () {
     powOn = 1  // Is this usable
}
}

// or should it just be done this way
digitalWrite(powON, HIGH);   // is this the only usable way


I guess what I'm asking is can you just set a pin high by using a 1 or do you have to use digitalWrite for
outputs
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34725
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
 powOn = 1  // Is this usable
All that does is to set thevalue of the variable to one, not the state of the pin. You need digitalWrite or direct port manipulation to do this.
Logged

Offline Offline
Sr. Member
****
Karma: 3
Posts: 263
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks It was looking like that's the only way so Now I no thanks

Logged

Pages: [1]   Go Up
Jump to: