this post was submitted on 21 Aug 2026
8 points (100.0% liked)

Arduino

543 readers
5 users here now

Arduino is an open-source electronic prototyping platform enabling users to create interactive electronic objects.

founded 3 years ago
MODERATORS
 

Hello Friends :)

I've been re-teaching myself Arduino to brush up on my C/C++ and I've been working on this project for a simple adding machine with two user inputs and a single visual output. I'm not sure what is wrong with my code.

As it stands, the code compiles without error or warning and runs on my Uno R3, but as soon as I press "NumberEntryButton" to begin building the first number, pin 13 immediately flashes 8 times, then stays solid on.

If anyone has advice or help to offer, I'd super appreciate it.

I've attached a permalink to the file in my git repo.

you are viewing a single comment's thread
view the rest of the comments
[โ€“] one_old_coder@piefed.social 4 points 1 week ago* (last edited 1 week ago) (1 children)

My 2 shitty cents because I haven't done Arduino for a long time:

  • AddTwoNumbers and ShowResultToUser are useless. Put their content in the loop() function because it's very unlikely you will reuse such a code.
  • The for loop in ShowResultToUser is strange. You're calling AddTwoNumbers all the time. Maybe do something like for (int i = 0, n = GetNumber() + GetNumber(); i < n; i++)? That's more traditional.
  • In FlashLed, I would add another delay at the end, like show/delay/hide/delay or something.
  • The GetNumber function is confusing, add a comment to explain what it does.
  • Move all the constants as global constants. You have 8 and 9 in setup and GetNumber, 13 in setup and FlashLed, but what happens when you want to change a pin? You have to change the values everywhere.

This is great feedback, thank you.