If you use the digitalWrite() function with 16MHz clock, the max freq is 142 KHz. Using a macro like #define SET(x,y) (x|=(1<<y)) or #define CLR(x,y) (x&=(~(1<<y))) you can reach 4 MHZ!!.Read more: at Bill Porter´s site