7 Segment Display Counter using shift register and push button

Hi

I am not very confident with arduino yet but I am trying to increment my 7 segment display by 1 each time the button is pressed, I also have a shift register in my circuit.

However I can only seem to get the button to start the display incrementing from 0 to F, I want to press the button for it to move to each bit ie 0 press button 1 press button 2 and so on.

I think this is where my code is wrong:
if (buttonState ==HIGH) {
for (int i = 0; i<16; i++) {
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, numberToDisplay*);*

Please read the forum guide in the "please read" sticky post. Then you can modify your post above and we will be in a position to help you.

PaulRB:
Please read the forum guide in the "please read" sticky post. Then you can modify your post above and we will be in a position to help you.

I'm stealing that.

I prefer:


OK, first things first.

You need to go and read the forum instructions so that you can go back and modify your original posts (not re-post them) - using the "More -> Modify" option below the right hand corner of your post - to mark up your code as such using the "</>" icon in the posting window. Just highlight each section of code (or output if you need to post that) from the IDE and click the icon.

In fact, the IDE has a "copy for forum" link to put these markings on a highlighted block for you so you then just paste it here in a posting window. But even before doing that, don't forget to use the "Auto-Format" (Ctrl-T) option first to make it easy to read. If you do not post it as "code" it can as you now see, be quite garbled and is always more difficult to read due to the font.

It is inappropriate to attach it as a ".ino" file unless it is clearly too long to include in the post proper. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And even that would also assume they are using a PC and have the IDE running on that PC.

Also tidy up your blank space. Do use blank lines, but only single blanks between complete functional blocks.


Modified according to how many posts of code and how thoroughly garbled.