Drive a 7-Segment LED with an Arduino

Last week I took a day off work and started experimenting with Arduino. Arduino is an open-source electronics prototyping platform that enables anyone to create interactive objects. During the week I started doing basic stuff using simple components such as blinking LEDs and playing tunes with a buzzer, and yesterday I experimented with multiple LEDs. After that I wanted to try and do something with a 7-Segment LED display so I found this tutorial that enabled me to make the circuit and learn the code that should drive the display.

Unfortunately the provided code did not work and I had to modify a lot of parts to finally get the display to work. I had to invert the “HIGH” and “LOW” params in all the function calls and change the way the constants are defined in the beginning.

I can’t really explain to you why there is such a difference between my working code and the code provided in the article I based myself on since I’m still a beginner. I might be using a different display and a different version of the IDE. When I’m advanced enough to figure that out I’ll make sure to update the article. If you can explain the reason to me please do so in the comments.

Here’s the updated code, I also created an additional function that plays a little “snake” animation on the display. Continue reading “Drive a 7-Segment LED with an Arduino”