Originally Posted by
DjNecro
Mmmmmm port manipulation... *drool* You can call me Mr. Bit Twiddler
On a serious note though... Direct port access would be pretty much required for any serious project. There's just so much overhead involved when using digitalwrite/read that there's really not much that can be done to speed things up past a certain point.
It can be tricky to wrap your mind around
Yeh your totally right about the usage to run a digital write command, I found this page where this guy had tested the difference between digitalwrite and port manipulation and found port manipulation to be 10 times faster, he also explains how to do it...
http://www.instructables.com/id/Ardu...how-to-fix-it/
Here is the bit of code I use for MUXing, I replaced the code in my last post with this to get things up to speed for multiplexing my LED VU meter, the code is also shorter and 'nice to look at' ...
PHP Code:
void multiplex(byte mp_number_man){
byte port_b_out[8] = { 0x0, 0x8, 0x4, 0xC, 0x2, 0xA, 0x6, 0xE };
PORTB = port_b_out[mp_number_man];
}
This code is quite specific to the pin numbers the MUX control lines are connected to on the Arduino. Both the hex values and 'PORTB' need to be set correctly (the link above explains pretty well). This particular code however, should work if the A,B,C control inputs on the MUX are connected to Arduino pins 11, 10, 9
Bookmarks