how to use 8 of the digital i/o pins at same time?

Hi i want to know how to use 8 of the digital i/o pins at the same time?

e.g. pins 1,2,3,4,5,6,7 and 8 has output value of
1,0,1,0,0,1,0 and 1 (which will be keep changing)

How can i output this data simultaneously without any delay between two output signals??

the command
int pin1 = 1 ;
pinMode(pin1, OUTPUT);
digitalWrite( pin1, HIGH);
will drive only one pin at a time. So how to drive multiple pins at the same time?

thanks in advance :slight_smile:

You will have to use direct port manipulation (google the term). With direct port manipulation all pins of the port you are switching are switched simultaneously, but the code will get a bit more complicated.

It depends on what you mean by "the same time" Surely any processor can only operate on one instruction at a time (and that includes the best proecssor of all - the human brain) and as such no two events can occur simultaneously. This "drawback" is used effectively in programmable control systems to ensure "simultaneous" sequences occur in the correct order However you can surely produce a routine to set up and then switch outputs on a single given command - but even then events will not be exactly simultaneous jack jack

@jackrae : yes you can run multiple pins/ outputs simultaneous and is called parallel processing! (my be a minor delay in nano seconds)

@Otacon2k: Thanks a lot mate! That’s what i needed to know!
i’m checking this

http://www.arduino.cc/en/Reference/PortManipulation

it seems to address the issue…
Thank for you help!!! ;D

is called parallel processing

No, parallel processing is something quite different.

No, parallel processing is something quite different.

Just what I was thinking.....

You can only change bits of the same port at the same time. Even then they don't actually change sanctimoniously. In fact it is part of Einstein's theory of relativity that these is no such thing as a simultaneous event. This is why in electronics things are often synchronised by a clock pulse or strobe signal which indicates all the relevant data lines have stable data on them. Parallel processing involves more than one CPU, in practice they never have access to the same i/o address space so it is on no help in getting things to happen simultaneously.

You will probably find that you don't need to have things happening simultaneously.

What about quantum computing? Can't they do an infinite number of operations at the same time? ;D

But the question related to Arduino - not some device that might stretch our personal (or national) budgets. Basic question still stands - what do you mean by simultaneous "exactly so or just about so" jack

But the question related to Arduino - not some device that might stretch our personal (or national) budgets. Basic question still stands - what do you mean by simultaneous "exactly so or just about so" jack

Agreed. I was just being a bit of an @$$ haha :).

What about quantum computing? Can't they do an infinite number of operations at the same time?

No.

Really? I swear I saw a special somewhere saying the quantum mechanics stated that any individual atom has an infinite number of states in which it exists at the same time.

Perhaps not :P.

Really? I swear I saw a special somewhere saying the quantum mechanics stated that any individual atom has an infinite number of states in which it exists at the same time.

An individual atom can exist in multiple states but it does not mean that you can perform multiple events at the same time...

Mowcius

An individual atom can exist in multiple states

But when you measure what state it is in the other states collapse and you end up with just one state. Therefore there is no way to extract information about the state. It's called Heisenberg uncertainty principle. http://en.wikipedia.org/wiki/Uncertainty_principle

But when you measure what state it is in the other states collapse and you end up with just one state. Therefore there is no way to extract information about the state. It's called Heisenberg uncertainty principle.

Indeed. Reminds me of learning about wave-particle duality at school... Oh the joys of physics :p

Mowcius

It's called Heisenberg uncertainty principle

You sure about that? ;D

You sure about that

Yes! ;)

My collogues at the University always said I embodied the principle very well. If you knew where I was you didn't know what I was doing but if you know what I was doing you didn't know where I was.

My collogues at the University always said I embodied the principle very well. If you knew where I was you didn't know what I was doing but if you know what I was doing you didn't know where I was.

Haha ;D

Did we just stop tying to help the OP?

The Arduino port-to-pin mapping structure might make it more difficult than you desire if you want to work with say a full 8 bits (pins) at once.

The easiest way to do what you want involves digging deep into the chip itself and start manipulating chip hardware ports/pins (see data sheet) with "bytes" of data. (all 8 or less pins of a port could be changed by the byte value). This is sort of non-trivial since you need to understand the mapping of the PINS and how it relates to hardware ports.

If you really need to make a bunch of pins operate simultaneously... you might be better served by a serial shift register(74hc595).

I thought we had sorted him out?

Yes a shift register would allow byte wide presentation of data as would a MCP23008 or MCP23016 or a MCP23S17. That last one has an SPI interface and so is very fast.