Pages: [1]   Go Down
Author Topic: Easier digital output  (Read 502 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there a quicker way I can control several digital pins without having to use "digitalWrite" every time?
Logged

Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If they're all on the same port, you can use Port Manipulation, or you could put all your pin numbers in an array and loop through the array:
Code:
byte pin_numbers[] = {3, 4, 6, 7, 8, 9}

for (byte i=0;i<6;i++) {
  digitalWrite(i, HIGH);
}

However, that is slower to execute. Then, there is always copy+paste smiley
Logged

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

Note here that slower is a relative term and in practice you will not see any difference. This is the way to do it.
Logged

Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 510
Posts: 19306
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there a quicker way I can control several digital pins without having to use "digitalWrite" every time?

Why do you want to?
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Pages: [1]   Go Up
Jump to: