Arduino 2-Digit 7-Segment Display with Buttons: Sketch

Posted June 29th, 2010 by Natalia and filed in Arduino, Project

As you could see from last week’s full Arduino sketch listing, the source code for the 2-digit 7-segment display project using buttons is strikingly similar to the one without the buttons; praise for ‘copy and paste‘! (It is worth noting, though, that ‘copy and paste‘ can be responsible for a higher percentage of bugs than I’d care to admit).

There are just a couple of snippets that I would like to comment on:

The first part of the loop() function checks whether either button has been pressed and increments the value of each digit.
Continue Reading »

Arduino 2-Digit 7-Segment Display with Buttons

Posted June 22nd, 2010 by Natalia and filed in Arduino, Project

This week we modify the original circuit and sketch to include two buttons, one to control each digit of the display.

Here’s what the setup looks like:

2-Digit 7-Segment Display

And here’s the complete sketch:
Continue Reading »

Arduino 2-Digit 7-Segment Display Counter: Sketch

Posted June 15th, 2010 by Natalia and filed in Arduino, Project

This is part 3 in the project to control a 2-digit 7-segment display using an Arduino. Here is the first post on this 2-digit 7-segment display project.

So now on the the meatier sections of the sketch for this project:

Common anode displays are not immediately obvious as a segment is lit when the corresponding pin is made LOW. You might be surprised, though, that common anode displays are most often used because they can be used with 74xx series logic data-selector chips and PNP bipolar transistors.
Continue Reading »

Arduino 2-Digit 7-Segment Display Counter

Posted June 1st, 2010 by Natalia and filed in Arduino, Project

2-digit 7-segment displayThis month’s Arduino project is to build two 2-digit 7-segment LED display circuits and sketches, one that counts up and one that counts up using mini push buttons. The next posts will explain the circuits and the Arduino sketches.

Materials:

Sketch for counting up without buttons:
Continue Reading »

Controlling a Seven-Segment Display Using Arduino Part 4

Posted February 22nd, 2010 by Natalia and filed in Arduino, Project

The third and final Arduino sketch uses bits to represent each segment and is a reduced code version of the previous sketch (1,210 bytes for sketch #3 instead of 1,852 bytes for sketch #2). A ten element array holds a byte for each number 0-9 that specifies what segments should be lit (pin low). Bit 0 corresponds to segment A, bit 1 to segment B and so on. In order to display the number 1, segments B and C need to be lit, so that is represented by the value 0b1111001. Function “lightSegments” reads these bits in sequence and sets the corresponding segments accordingly.

Continue Reading »

Controlling a Seven-Segment Display Using Arduino Part 3

Posted February 15th, 2010 by Natalia and filed in Arduino, Project

The second sketch cycles through the numbers from 0 to 9, but only increments the display counter each time a button is pressed. Note that this code includes simple debouncing by introducing a short delay when the Arduino detects that the button has been pressed.

Continue Reading »

Controlling a Seven-Segment Display Using Arduino Part 2

Posted February 8th, 2010 by Natalia and filed in Arduino, Project

This month’s project is a simple program to display the Arabic numbers using the Arduino and a 7-segment display.

Parts list:

Continue Reading »