It takes 9 leads to connect one of these display modules. Multiplexing and other techniques allow us to use fewer wires and interface larger displays. This project uses a chip called the LS74HC595 shift register. Try the simulated shift register experience for more information.
Build this Arduino CircuitIt will run the assembly program from ATmega328 C++ program library 7 segment with the same result. These screencaptures are from the SimulIDE program.
It still works this way. Notice the criss-cross of wires going to the LED module? We try to line up components to reduce connections and distances. We are making sure segment a of the display is connected to data IO Q0 of the shift register, we want the top bar to be the LSB least significant bit.
Hardware ConnectionsLook at the graphic below and how a single bit moves along from pin Q0 to Q7 of the shift register. The Uno pulses a voltage on pin9 and DS data pin of the shift register turns it into a 1 bit on Q0. That voltage "walks" down the pins to Q7 and the Uno pulses a new bit.
Pin10 OE output enable is connected and off so the display stays on. A pulse on Arduino pin11 tells clock pin STC to synchronize the shift register. Latch Pin12 SHC and pin13 MR memory reset are held high.
We're seeing a demonstration program. It was generated with a simple assembly language program that just makes the bit walk. The program is an attachment.
Install ShiftDisplay LibraryUpdate your Arduino libraries and install ShiftDisplay. This will add code so we can drive 7 segment displays through a shift register like the LS74HC595.
Replace the default code with this sketch. It prints an integer variable named m to our display then increments m. When m reaches 10 it restarts at 0.
/*
* count m = 0 to 9 on seven segment display Arduino and LS74HC595 shift register
*/
#include <ShiftDisplay.h>
#define SCLK 11 // SCLK STC portb.3 pin11 clock
#define RCLK 12 // RCLK SHC portb.4 pin12 latch
#define DIO 9 // Data input to shift register
ShiftDisplay display(SCLK, RCLK, DIO, COMMON_CATHODE, 1);
void setup() { }
void loop() {
static int m = 0;
display.set(m, ALIGN_LEFT);
int pos = m < 10 ? 0 : 1;
display.setDot(pos, true);
display.show(200);
display.setDot(pos, false);
display.show(200);
m++;
}
The Uno pins connecting the shift register device are identified and a data object named display is created. How to calculate display(variables) is declared in a header file called ShiftDisplay.h.
We have a single LED module and it is COMMON_CATHODE electrical type. Positive voltages are applied to the display segments to light. It is not common anode.
Adding the library means we can use new commands. We print our characters with a display.set(value, align) command, we delay with display.show(ms).
UploadUpload and you should see the display count up. The simulator shows more activity as pin12 SHC flickers at the end of each 8bit byte. Pin13 MR is still held high. This driver software is using more of the pins.
Add display modules. The software allows it just by changing a variable. We only have one LED display module.
Your Arduino IDE will have a new folder of extra example programs. They will work when you change the pin numbers and select COMMON_CATHODE.
One example in the library takes digits and text from the serial port and displays on seven segment modules. Another scans the I2C bus and reports connected device addresses.
SimulIDE comes with many projects ready to teach you electronics and computing. I am using code from their examples for these projects.
Try the assembly code in hardware project. It compiles with MicroChip and Avra. You can try on-line assemblers.
Websearch for more code you can try and more challenging applications. This table may help you decypher what you find. Notice how many names for the same thing?
Comments