Pages: [1]   Go Down
Author Topic: Easier digital output  (Read 495 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: 634
Posts: 34527
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
Offline Offline
Brattain Member
*****
Karma: 497
Posts: 19055
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


Pages: [1]   Go Up
Jump to: