r/ArduinoProjects • • Aug 10 '22

8 bit binary counter

Hey there! I'm new to this subreddit and I've just started to work with my Arduino UNO R3. I've created an 8bit binary counter(inspired by another fellow Arduino user).

Here's the repository link:- https://github.com/Noobsiecoder/arduino-projects/tree/main/src%2F8bit-manipulator

153 Upvotes

9 comments sorted by

2

u/noobsie_boi Aug 11 '22

Sincere apologies, its a 4 bit binary counter. Thanks for the help redditors! :)

19

u/ChezLong Aug 10 '22

4 bit surely? (cue for "don't call me Shirley" replies...)

3

u/cr0sis8bv Aug 10 '22

can confirm

4

u/planeturban Aug 10 '22

I can also confirm this.

Source: have had eyes all my life.

6

u/planeturban Aug 10 '22 edited Aug 10 '22

Jokes about 8/4 bit aside. This is a nice way to learn about port manipulation. If you were to connect your leds to A0-3 and do something like this, you'd end up with a smaller program:

void setup()
{
 DDRC = 15; // set analog pin 0-3 to outputs, 15 == binary 1111 hence all as outputs.
}
void loop()
{
 for (int j = 0; j < 16; j++) {
    PORTC = 0; // turn all leds off
    PORTC = j; // write value to leds.
    delay(500);
 }
 delay(1000);
}

It's called port manipulation if you want to read more about it.

(Disclaimer, I did this from memory so I might have mixed my registers up, but it looks ok. If someone sees an error, please correct. :) )

Happy coding!

Edit: checked the code, seems to work.

2

u/User95409 Aug 11 '22

This is how it all starts!

1

u/Appropriate_Swim1574 Aug 11 '22

I think it is 4 bit