Tutorials in this section:
Connections to the Arduino board
In the example photo, I have soldered female pin headers onto the DSP0801. This makes it easy to connect to the Arduino using pre-crimped hookup wires. Connect all the wires as shown below. As we're only using a single display, we can ignore all the other headers for this example.
Click to enlarge
I'm using the UNO board, but any version of the Arduino should work in much the same way.
Arduino | DSP-0801 JP1 | |
GND (any) | GND | |
12 | SIN | |
11 | CLK | |
10 | LAT | |
9 | BL | |
+5V | VCC |
After making all connections, connect your Arduino board to your PC and upload the example sketch. You will most likely need to power-cycle the board once after uploading. I find this eliminates any problems with garbage appearing on the display. From then on, everything should work just fine and the display will function normally right from power-on.
14 Segment Character Table
Here are some examples of the HEX codes I've used to print characters on the display. Each character needs 16 bits of data. As we're using an 8-bit platform we'll need to send each character to the display 8 bits at a time. Refer to the source code to see how this is accomplished.
A 0x00F7 G 0x00BD M 0x1536 S 0x909 Y 0x1500 B 0x00BF H 0x00F6 N 0x936 T 0x1201 Z 0x2409 C 0x0039 I 0x1209 O 0x003F U 0x003E D 0x120F J 0x001E P 0x00F3 V 0x2430 E 0x0079 K 0xC70 Q 0x83F W 0x2A36 F 0x0071 L 0x0038 R 0x8F3 X 0x2D00
1 0x0406 2 0x00DB 3 0x00CF 4 0x00E6 5 0x00ED 6 0x00FD 7 0x0007 8 0x00FF 9 0x00EF 0 0x243F
For decimal point, add 0x4000 to any character code. For example, a Zero (0) followed by a decimal point would be represented as 0x643F instead of 0x243F.
Making special characters
"Special" characters are also possible. To create your own, follow this procedure:
D15 D14 D13 D12 D11 D10 D09 D08 D07 D06 D05 D04 D03 D02 D01 D00 <- Data bits NC DP N M L K J H G1 G2 F E D C B A <- Display segments
Refer to the DSP0801 datasheet to see which letters correspond to which segments, and make note of which ones you need to display the character of your choice. For this example, let's make a PLUS(+) sign, which will require segments G1, G2, J and M. When a segment should be lit, that data bit should be set as 1. If it should be unlit, 0. This gives us:
D15 D14 D13 D12 D11 D10 D09 D08 D07 D06 D05 D04 D03 D02 D01 D00 <- Data bits NC DP N M L K J H G1 G2 F E D C B A <- Display segments 0 0 0 1 0 0 1 0 1 1 0 0 0 0 0 0 <- Character data
The resulting binary number, 0b0001001011000000 is a bit unweildy, and hard on the eyes. I found a lot of errors crept in when trying to type these out for each character, so it's easier to convert the values into HEX. Thankfully, Google makes this incredibly easy (just type it in the search bar!). So we end up with:
0b0001001011000000 = 0x12C0
Which is much nicer to use in a program, and makes it easier to spot any errors.
Compile, upload and run the example program for a scrolling text demonstration and to see how it all works.
Example code:
//DSP-0801 TEST PROGRAM //For Arduino IDE //pin definitions, using the shiftOut function to communicate with the display const int SDATA = 12; //to SIN on JP1 const int CLOCK = 11; //to CLK on JP1 const int LATCH = 10; //to LAT on JP1 const int BLANK = 9; //to BL on JP1 //BL pin on JP1 MUST be pulled LOW, we will do this in software //Display brightness can also be controlled through PWM using AnalogWrite function void setup () { //set all pins to output pinMode(SDATA, OUTPUT); pinMode(CLOCK, OUTPUT); pinMode(LATCH, OUTPUT); pinMode(BLANK, OUTPUT); digitalWrite(BLANK, LOW); //for this example, BLANK is held LOW throughout //allow DSP-0801's onboard PIC to wake up before sending any data delay(500); //send 8 blank digits to clear all registers, not always necessary but good practice for(int i = 0; i < 8; i++) { digitalWrite(LATCH, LOW); shiftOut(SDATA, CLOCK, MSBFIRST, 0x0000); //data must be sent one byte at a time shiftOut(SDATA, CLOCK, MSBFIRST, 0x0000); digitalWrite(LATCH, HIGH); } } void loop () { //defines how fast digits will scroll int scrollRate = 200; //character table array - what we want to put on the display goes in here, in this //case: //"DSP0801 THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG " //refer to 14-segment character code document for HEX values word charTable[55] = { 0x120F, 0x909, 0x00F3, 0x243F, 0x00FF, 0x243F, 0x406, 0x0000, 0x1201, 0x00F6, 0x0079, 0x0000, 0x83F, 0x003E, 0x1209, 0x0039, 0xC70, 0x0000, 0x00BF, 0x8F3, 0x003F, 0x2A36, 0x936, 0x0000, 0x0071, 0x003F, 0x2D00, 0x0000, 0x001E, 0x003E, 0x1536, 0x00F3, 0x909, 0x0000, 0x003F, 0x2430, 0x0079, 0x8F3, 0x0000, 0x1201, 0x00F6, 0x0079, 0x0000, 0x0038, 0x00F7, 0x2409, 0x1500, 0x0000, 0x120F, 0x003F, 0x00BD, 0x0000, 0x0000, 0x0000, 0x0000 }; //get characters from array one at a time ready to be shifted out for(int index = 0; index < 55; index++){ word charData = charTable[index]; //shift out the value currently held in charData digitalWrite(LATCH, LOW); shiftOut(SDATA, CLOCK, MSBFIRST, (charData >> 8)); //send one byte shiftOut(SDATA, CLOCK, MSBFIRST, charData); //then the other digitalWrite(LATCH, HIGH); delay(scrollRate); } }
Or you can download a copy on the download page.
- Jez Thomas