Friday, 9 October 2009

7-segment LED display projects

I completed the Digital Display chapter. I had so much fun in this chapter and I would like to share some of the projects that I did.
First i'll give you some information and facts about 7-segment LED displays.
A 7–segment display is a rectangular block of 7 lines of equal length that can be lit selectively to display digits and some letters.
Here are two pictures of how to work the display and the schematic for the 7-segment.


Pin numbers.



Schematic drawing for 7-segment LED display.


 The Common Cathode means that all the cathodes (negative connection) are connected together (they share a common connection point).

Some interesting facts –
- The 7-segment LED display is called a parallel device because you have to use more than one I/O line at a time to send data to the device.
- The wires that transmit the HIGH/LOW signals from the BASIC Stamp to the 7-segment LED display are called a parallel bus.

I’m going to show you now how to display some digits:
- There are 8 different BASIC Stamp I/O pins that send high/low signals to the 7-segment LED display

REMINDER:
8 bits: A binary number that has 8 digits is said to have 8 bits. Each bit is a slot where you can store either a 1 or a 0.
A byte is a variable that contains 8 bits.

Special Variables:
DIRH – A variable that controls the direction (input or output) of I/O pins P8 through P15.
OUTH – Controls the high or low signals that each I/O pin sends.

Here is a program that displays the digits 0 through 9 on the display -






 Schematic diagram for the 7-segment LED display.
The video –



How it works:
OUTH = 000000 initially turns off all the LED’s. (8 zero’s because there are 8 sets of I/O pins; P8 through P15)
DIRH = %11111111 sets all I/O pins P8 through P15 to outputs.

*The % is used to tell the BASIC Stamp Editor that the number is a binary number. Example: The binary number 001100 is the same as the decimal number 12.*
*All BASIC Stamp I/O pins start out as inputs.* - This is called a “default”. You have to tell a BASIC Stamp I/O pin to become an output before it starts sending a high or low signal.

I then spelt out A through F –



A through F video –



After I learned how to display numbers and letters and decided to experiment and spell something out of my own –




I spelt out ‘Richard is cool’. Here is the video –

Watch the video –


Notice I added a full stop at the end and did a blink at the O’s, I did those by my self.
I then learned how to make things easier with the LOOKUP command, that let’s you ‘look up’ elements in a list.

Example –
LOOKUP index, [ 7, 85, 19, 167, 28], value

2 variables – index and value.
If the index is 0, value stores the 7.
If index is 1, value stores 85, and so on.

I was then introduced to the LOOKDOWN command that gives you an index based on a number (the opposite to LOOKUP).

So in the previous programs instead of writing a whole huge list one by one what I want to spell out, I can just write a list of the numbers or letters that I’m going to be using, and then write in square brackets what I want to say, and the LOOKUP command will see in order what letter I want to spell, lets say A, so it goes and looks for the letter A in the list, reads the binary code and flashes it out. This saves time and prevents mistakes to be done in writing the binary code over and over. You will see this in the FISH CHIP And dIP example.

In this program I spelt out FISH CHIPS And dIP using the LOOKUP command. -




Here’s the Video –

 

Oh yeah, here’s a picture of my work station :). Notice the awesome Norway picture on the right guy’s! And I got a small shelf for my components, it’s under the speaker and it cost only £1.25 from the charity shop, it smells a bit like electricity ;) – I just have to put labels and start using it.



My work station.

Enjoy!





2 comments:

  1. Aw man, sorry guy's I have some sereous glitches on this post, maybe because I copied and pasted it from word. So whenever you see Example: OUTH = 000000, it really should be OUTH = 000000. and when its OUTH = 010100 (the % and two high or low signals are missing)
    I tried fixing it but it wouldnt change. I'll retype it another time.

    ReplyDelete
  2. Hey man this is Awesome!

    I really like the fact that you are doing hand drawn schematics as well: very very good - and great that you are posting them here as well! They really help clarify things.

    And great job on spelling out richard is cool :) Thats the kind of stuff that we want to see: you taking what you've learned and then applying it to do something of your own design. Well Done!!

    PS we can talk about posting issues later. remember that what you post is often read by the browser as html code so some symbols get interpreted not the way you intended, especially when you are writing in code from another language.

    ReplyDelete