Hi,
I want to move 8 bits of data to the port D(pins 0-7 on the diecimila) simultaneously. Is there a single function that I can
use to do it?
I think I can use shiftOut() function or even manually extract the bits and send them using digitalWrite().
However, if the same thing can be done using a single function, then I would like to use that.
I am very new to arduino, so what I have asked may be silly or very naive. I did perform some searches for my problem, but unfortunately did not get any results for what I was looking for.
Hi,
you have access to the port D on the Arduino with the command PORTD. You still have to set the io-pins as outputs, but then you can simply write fro instance
PORTD=B10101010;
to update all of the 8 pins with one command.
Eberhard
DDRD = 0xFF; // make pins 0 - 7 outputs
PORTD = byte; // byte is the 8 bits you want to output in parallel
This is a case where it’s useful to peruse the mega168 datasheet and understand how the microcontroller’s registers work. The above code will take 125 ns to execute (note that digitalWrite() on a single pin takes several microseconds).
Ben
Edit: Wow, posted at exactly the same time as Eberhard (all the way down to the same second)!