program for digital modulo 7 under arduino

Hello my friends,
I want to make a digital counter modulo 7 by using the arduino board but I do not know how to achieve it. anyone can help me? want a sample program in arduino which is the same thing?

thank you in advance

Set a counter to zero. Add one to it until it reaches the required value then reset it back to zero ? Repeat.

If this is not what you mean can you please provide more details and/or sample output from such a counter ?

I want a program that generates 7 digital outputs will vary of 0000000, 0000001 ....... to 1111111

If you want to set 7 digital outputs to represent the bits of a variable then here is a variation on my original suggestion

Use a for loop from 0 to 127 (7 bits). For each step in the for loop read each of the 7 bits of the loop variable and set the associated pin HIGH or LOW as appropriate.


Use the same for loop, output the loop variable to a shift register bit by bit and use the outputs of the shift register to drive the pins.

hello my friend
thank you very much
can you give me an example program

Is this a college or school assignment ?

Here is a program that does most of what you want. I will leave it to you to improve it.

void setup() 
  for (byte i = 0; i < 128; i++)
    Serial.println(i, BIN);

void loop() 

thank you very much