Help! 2 Counters both run by a different button displayed on 7 segment display

I'm pretty new to Arduino and am trying to create a program that will run 2 counters. I will be using a button to increment the counters, each counter has its own button. Then I will be displaying the counts to 4 digits 7 segment displays. I am currently having problems with the displays, they occasionally increment, but for the most part, just say 0000.

I am attaching the program I have made. It is kinda long so I am attaching it as a document. Please help and tell me what I am doing wrong. Thanks in advance!

Final_Project.ino (10.6 KB)

  1. You should be detecting the change between a switch being off and on rather than just looking at the current value of the switch.

  2. The way you describe it the two switches are independent, so why are you checking both switches in every 'if' statement?

  3. Read up on how to use "arrays" and you can reduce the size of your code by half at least.

How are your switches connected? Have you tested them independently of the display with a simple test sketch that only exercises the switches (maybe reports via serial)? Often people fail to connect switches properly or get the circuit wrong.

You should be detecting the change between

Or, actually, https://simple-circuit.com/ should...

I'm pretty new to Arduino and am trying to create a program that will run 2 counters. I will be using a button to increment the counters, each counter has its own button. Then I will be displaying the counts to 4 digits 7 segment displays. I am currently having problems with the displays, they occasionally increment, but for the most part, just say 0000. I would love if someone could look at what I've done or sends a code they have made before, and just make it so it works.

I am attaching the program I have made. It is kinda long so I am attaching it as a document. Please help and tell me what I am doing wrong. Thanks in advance!

Final_Project.ino (10.6 KB)

Several things wrong.

  1. you didn't bother to read the forum guidelines (as linked at the top of every board) which a.o. help you to ask a good question,
  2. you cross posted,
  3. you forgot to explain what the code does and how it differs from what you expect it to do.

#2 and #3 you would have known had you done #1.

@mdailey130

Other post/duplicate MOVED AND MERGED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.