NASA-Threads Electricity and Magnetism Lesson 8: 7-Segment Display
We will start off by creating a program that determines if the user inputs a vowel/consonant, and then blinks an
LED according to this input.
This program uses an IF : THEN program as well as subroutines.
In this activity, you will use the DEBUGIN command to
Needed
Boe-Bot
Computer with BASIC
Stamp Editor program
USB cable
Dual 7-segment display
Two 220 resistors
Boe-Bot wires tell the Boe-Bot, through the Debug Terminal, which blink pattern to execute.
Write a program that will tell the Boe-Bot to execute one blink pattern if a vowel is entered and another blink pattern if a constant is entered.
Below is how the main routine should look. Create your own subroutines for each circumstance. If you open the Vowel Routine worksheet, there you will find a code that can be copied and pasted into the Basic Stamp Editor.
Use FOR : NEXT loops with a counter in your subroutines to make your blink pattern loop for about 10 times.
NASA-Threads Electricity and Magnetism Lesson 8: 7-Segment Display
The rest of today’s lesson will be spent setting up the 7-segment display. We will use a brute force method in class and the students will use subroutines for homework.
P u r r p o s e assembling circuitry, and programming.
N A S A a p p l i i c a t t i i o n: Similar technology and the basic theory are used to perform actual count downs for shuttle and rocket launches today.
The 7-segments are typically labeled clockwise starting with their letter “A” at the top most segment and ending with “G” at the center segment. If the display contains a decimal point, it is labeled DP.
You will be using a 0.4” Dual Digit LED Display. This display is composed of two 7-segment displays combined into a single unit with 18 pins.
The display has 18 pins that plug directly into the Boe-Bot breadboard. The pins are numbered counterclockwise starting at the bottom left corner.
M a t t e r i i a l l s
Dual 7-segment display
Boe-Bot wires (You will probably want to have pre-stripped wires for the students.)
Two 220 resistors
P r r o c e d u r e
The students will work in pairs.
1.
Before you start working with the 7-segment display, make sure you unplug anything connected to pins 0 – 15. This includes the servo motors. Insert the display into the
NASA-Threads Electricity and Magnetism Lesson 8: 7-Segment Display
Boe-Bot breadboard and setup the circuit shown below. You will have to use all 16 Boe-
Bot pins.
Notice that voltage is supplied to the display module from Vdd through the two 220 resistors, and this voltage is wired internally to each of the 14 display elements. The other side of each display element is connected to pins 0 – 15 of the Boe-Bot.
The result of this connection scheme is that when a LOW signal is generated at any of the
I/O pins, then the display element will be on. When an I/O pin is putting out a LOW value, then there is a path for current to flow from Vdd, through of the 220
resistors, through one of the display elements and into the I/O pin that is putting out 0 V. When an I/O pin is generating a HIGH signal, then there is no difference in voltage between Vdd and the I/O pin, so no current flows and the display element is off.
NASA-Threads Electricity and Magnetism Lesson 8: 7-Segment Display
The diagram below will help determine which Boe-Bot pins to activate to form certain numbers.
2.
Program the Boe-Bot to count down from 10 to 0 with one second intervals using
HIGH : LOW commands. Remember that to turn on a segment, you must set the pin LOW , and to turn off a segment, set the pin HIGH . While writing the program, observe that some segments may already be on and only turn on or off the needed segments.
Maintain the number zero in the first digit after the number 10; i.e. 10, 09, 08, 07…
Teachers: You can decide how much of the following code to give to the students and how much to let them discover on their own. The homework assignment tonight and in-class activity tomorrow asks the students to create subroutines to display 0 – 9 on each of the displays, and then write a program to count down from 99 – 00. The PBasic commands
DIRH and DIRL work very well here, so feel free to get the students to look at them.
NASA-Threads Electricity and Magnetism Lesson 8: 7-Segment Display
NASA-Threads Electricity and Magnetism Lesson 8: 7-Segment Display