Pages: [1]   Go Down
Author Topic: How to do parallel output efficiently  (Read 1377 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, ,i am an arduino beginner. i have a programming problem. Is there any efficient way to do the digital parallel output. While programming directly to AVR, we only need to give the data to PORTXn.
I use the following function to do so. But it may take a little long to finish writing. So i hope somebody can help me.
Thanks. smiley
Code:
int Dpin[]={3,4,5,6,7,8,9,10};

void sendPin(byte j)
{
        for (int n=0;n<8;n++)
      {
            if((0x01&j) < 0x01)
                {digitalWrite(Dpin[n],LOW);}
                else
                {digitalWrite(Dpin[n],HIGH);}
            j>>=1;
      }
}
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 631
Posts: 50133
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can do direct port manipulation on the Arduino, too.
http://www.arduino.cc/en/Reference/PortManipulation
Logged

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

Hi,PaulS
thank you so much. Would you please give me some suggestion or recommend some material about systematical Arduino programming learning?
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 631
Posts: 50133
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There's the whole reference section to be read and understood. Once you've done that, you'll know what else you need to learn. Asking specific questions will result in better answers than very vague "What should I study?" questions.
Logged

Pages: [1]   Go Up
Jump to: