Here is a n bit counter code for arduino... Its totally easy to use and you can modify it to create an alternate count way (count-up, count-down...). You can modify the number of bits and the max number to count.
Step 1: Download the Code, or Copy It.
You can download it from here.
Step 2: Edit It As You Want...
The code have some control constants to make it works fine...
Some of that constants is:
- Frecuencia: Its the number of samples per second that you wish.
- nbits: Its the number of bits that you want to have the counter (ex. nbits =4 ==> 1111)
- nMax: It is a number that determines to which number the counter can count.
- sal: It is a vector that have the pin number of the output.
You can change that numbers to modify it as you want.
Note: the sal vector numbers must be equal to nbits number.
Step 3: Upload the Code and Conect the Entire Circuit.
You can conect the arduino to some devices like: led array, a DAC, a FPGA...
Also you can view the functionality though the Serial...