You are on page 1of 21


SUNY Buffalo
Creating a Stop Watch with the Basic Stamp 2
MAE 476 - Mechatronics

Group B

Ilya Gartseev
Chris Van Loon
Jenna Curry
Ian Clark
Ian Duncan

Table of Contents

Abstract - pg. 3

Introduction - pg. 3

Theoretical Background - pg. 3-6

Testing - pg. 6

Problems Encountered - pg. 6-7

User Instructions - pg. 8

Schematics and Diagrams - pg. 9-13

Results - pg. 14

Description of Code - pg. 14-15

Conclusion - pg. 15

Contributions - pg. 15-16

Appendix - pg 17-22


The purpose of this project was to gain knowledge and familiarity with the Basic Stamp 2
microcontroller’s architecture and programming through the implementation of a digital
stopwatch. To accomplish this, Basic Stamp discovery kit was used, along with other
components such as, a seven segment numeric LED display, a LCD screen, and the MAXIM
MAX7219 display driver. The following report contains a detailed description of components
used along with their specifications, diagrams and schematics for the execution of digital
stopwatch. It also contains source code, user instructions and the theoretical background for
the project.

A microcontroller (MCU) is a small embedded dedicated device used for small and focused
applications. It consists of a simple CPU, clock, timers, input and output ports ROM, and
RAM. They are usually integrated with output components such as LED’s, LCD screens, or
even a small speaker. The MCU used in this experiment was the Basic Stamp 2 Integrated
Circuit Module (BSII) designed by Parallax, which gets its name from the fact it is the size of
an average stamp. It is programmed in a language called PBASIC.
The goal of this experiment was to utilize the Basic Stamp 2 module and specific peripherals
and integrate them to perform the task of a digital stop watch. A start, stop and reset button
were used along with a LCD display to display the time, a blinking LED to monitor every
second elapsed, a seven segment display to update the user on which button was pressed
and additionally a piezospeaker which beeps to let the user know audibly when a button was
pressed. Each button beeps at a different frequency to also let the user identify the button
The experiment was broken into different tasks which include integrating the LCD screen with
the BSII, integrating the piezospeaker, buttons and single LED to the BSII, and finally using
the MAX7219 to control the seven segment LED display. This made the project manageable
and allowed the members to work simultaneously on a common goal.

Theoretical Background
Code execution time
Our program essentially has a counter that increases every time one cycle is
completed. Each command is not instantaneous, it takes real time for the basic stamp to
execute. The time it takes to complete this depends on the function. In the course of one
counting cycle, our code takes a certain amount of time to execute. After completing our
calibration, we found that 184 cycles are completed every 1 second (5.43 ms/cycle). From
this information we can determine when to update the LCD.
When a button is pressed, the mechanical connection between the two momentarily is
unpredictable when the initial contact is made. This is due to the fact that when contact is
made the mechanical components will vibrate, therefore ‘touch’ and ‘un-touch’ each other. As
this occurs, a sample of the pin connected to this button may get an improper reading. De-

bouncing the circuit takes multiple samples of the button state successively to confirm that it
stays with the same reading for a prescribed amount of time. This was demonstrated in
experiment 14 with the following code:
btns = %1111 ' enable all four inputs
FOR idx = 1 TO 5
btns = btns & ~BtnBus ' test inputs
PAUSE 5 ' delay between tests
This code simply puts a pause between each sample and ensures that each state is the same
as the one before it.
ASCII (American Standard Code for Information Interchange) is a method in which you
can encode symbols (such as letters) by simple numbers. This standard has assigned
numbers to each symbol (given in a table below). As you can see from the table, digits 0-9 are
represented by 48 to 57 respectively. This makes the task of conversion very simple (simply
add 48 to the original digit).

Table 1. AscII printable characters

Pull Down Switches
Pull-down switches are one method that allows input from a user to determine the state of the
program. Pull down circuits have a switch connected to ground that is normally open. Usually
the circuit has a voltage across it, which is detected as a high, logic 1. When the button is
pressed, the connection to ground is completed. Now both ends of the circuit are connected
to ground and there is no voltage across the circuit, and the output is a low, logic zero. Hence,
the pull-down circuit is active logic low. This type of circuit is more resistance to noise than a
pull-up circuit, since in order to have a change in the state the voltage most change from 5V
all the way to 1.5 V, whereas the pull-up circuit can have a change in logic state if the voltage
changes from 0V to only 1.5 V.

Built -in Components

The Basic Stamp board that was used in this lab had many built in features to protect them
from high resistances and requires fewer external circuits that need to be wired. For example,
the 7-segment LEDs have built in resistors. Also, the pull-down switches are internally wired
with the necessary switch and resistors. Thus, only the inputs and outputs to the switches
need to be wired.

Light Emitting Diodes are components that emit light when current flows across them in only

one direction. With LEDs, it is, therefore, very important to connect them with the right polarity
since the LEDs will only allow current to flow in the correct direction, positive anode to
negative cathode, and the will break down the LED if wired incorrectly. Resistors are used to
limit the current across the diode to prevent it from burning out. LEDs function by releasing
energy when positive and negative charges recombine across a p-n junction.


We tested our system in a number of ways. We used sample programs and wiring diagrams
from the Stamp Works Manual. These helped determine if different pieces of hardware were
functioning properly. Experiments 1 through 3 were used to test the LEDs and learn how to
program for them. The LEDs lit correctly when the programs were run. Experiment 6 showed
us the commands necessary to use the buttons. The buttons were pressed and worked fine
with this code. Experiments 8 and 11 involved the seven segment LED and LCD respectively.
These codes demonstrated that both displays were working correctly and gave us the codes
needed to initialize them for our project.
We began our project by wiring the led to a pin and running the part of the program we wrote
for it. This presented no problems so we moved on to implementing hte buttons. Our first
attempt at the code had some bugs. Because we used the pause command with our button
command, short presses of the button to stop the timer were not registering. The code was
only checking for a button press every half second. We then decided to base the timer on the
length of time it took the code to process. This took some calibration, using a debug
statement in the loop and an existing stopwatch, but worked well. The seven segment and
LCD displays were added next. The initializations and a few other parts of the codes from the
experiments were used. The seven segment display showed the number of each button we
pushed. The LCD did not display the character we intended though. This led us to look into
the documentation for the device. We found the display used ASII code. We then changed
the code to reflect this and it worked. Debug statements were also used to make sure that
the code was moving to and from the proper subroutines. The statements were outputted to
a PC as the program ran so we could track the code's progress.

Problems Encountered

People working on projects of any nature ultimately run into problems. Solving the problem is
essential to getting a final product that works. Listed and described below are examples of
what problems our group faced while completing the lab. Also discussed is how we
eventually solved them.
One of the problems encountered dealt with writing to the 7 segment display. The example lab
using the MAX 7219 chip utilized all four 7 segment displays included on the board. Our lab
only required use with one of the 7 segment displays. We were getting unexpected results in
regard to the number that was being displayed. For example, a ‘4’ was being displayed, but
the top LED segment would be very dimly lit. We eventually realized that the initialization in
the experiment had the scan limit register to scan all four digits, when we only needed to scan
one. This is shown by the bolded constant (set to 1) in the serial transmission of data:

SHIFTOUT pin7sData, pin7sClock, MSBFIRST, [c7sOnlyDigit, 1]

Another problem encountered was the physical connection of the LCD display. We originally
connected the LCD in accordance with version 2.1 of the Stamp Works manual. This had a
slightly different connection than the connection described in the original documentation for
the LCD in version 1.2 The comparison is shown below:

Version 1.2

Version 2.1

As you can see these two schematics are slightly different. Our group didn’t originally hook it
up with a 4.7 K resistor. After this we could use the example experiment to enter in data to the
Another one of the main issues encountered also dealt with the LCD and how exactly
to output data to it. At the beginning we assumed that you would have to simply output the
number you wished to write to the LCD. This would work but it didn’t give the character we
wished. We may have tried something like 64 and get the symbol ‘@’. After thinking about it
we realized that this was simply ASCII representation. To convert, we output each digit
individually at its value added to 48 (See attached ASCII table)
The rest of the lab was fairly straight forward in regard to problems encountered.
These were the main holdups and how we dealt with them. Overall the lab was successful
and every member learned a lot about some of the inner workings of a lot of the components.

User Instructions

The set of user instructions below are to operate Group B’s BSII setup. It assumes the
program has been loaded to the modules memory and the power supply is plugged in.
Audible beeps will be heard to allow the user to identify which button was pressed.
• STEP 1
-Flip the power switch on the “stop watch”
- The green “on” LED should be lit. This indicates power is being supplied
to our project. If this is not lit, please the check connections. Also the
single red LED should not be lit this indicates the LCD counter has not
been initiated.

• STEP 2
- Press Button 1 (Start) [Location: D0]
- This starts the counting on the LCD screen. You should also see the “1”
displayed on the seven segment display. This indicates the start button
a.k.a. button one has been pressed. Concurrently you should see single
red LED blinking every second to match the counter with LCD screen.
• STEP 3
- Press Button 2 (Stop)[Location: D1]
- This buttons stops the counting on the LCD screen and leaves the
updated elapsed time on the display. The seven segments should display
a “2” to indicate button two has been pressed. At the same time the
single red LED should be off.
• STEP 4
- Press Button 3 (Reset)[Location: D2]
- This final button resets the time on the LCD screen and displays zeroes
consecutively. The seven segment display now displays a “3” to indicate
button three is pressed. The single red LED should remain lit to indicate
no time is being counted.

Repeat steps 1-3 to record elapsed time of various events. Also note that the stop button
does not have to be pressed in order to reset the LCD.

Schematic Drawings

The schematic of Lab1 hardware is shown on Figure 1. The design is made on the
StampWorksTM Experimental Board NX-10001 that is shown on Figure 2.
The dashed boxes highlight electrical components built into the NX-1000 board. The
integrated circuit U1 depicts Basic Stamp II (BS2) module2. Module LS1 is built-in sounder.
D2 is a one of the built-in LEDs. SWITCH1, SWITCH2, SWITCH3 are built-in buttons.
The integrated circuit MAX72193 is a serial input/output common-cathode display driver
that interfaces the BS2 to the 7-segment numeric LED display. Included on-chip are a BCD
decoder, segment and digit drivers, and an 8x8 static RAM that stores each digit. The external
resistor R6 is required to set the segment current for all LEDs. The external resistor R4 is
recommended by documentation.
The module COMPUTER shows RS-232/USB connection with personal computer and
can be used for the debug purpose.
Module LCD1 (LM020L) depicts parallel liquid crystal display with 2 rows and 16
columns. The module is connected to the NX-1000 board by 14-pin header. The module
contains built-in Hitachi HD44780 controller.
For integrated circuits, signals GROUND and POWER are not shown.

Parts list

Quantity References Value Order Code

3 Resistors
1 R3 4.7K, 1/2W, 5% 271-1124
2 R4,R6 10K, 1/2W, 5% 271-1126
2 Integrated Circuits

BS2-IC, Basic
1 U1 Stamp II module BS2-IC
1 U3 MAX7219 603-00001
2 Miscellaneous
StampWorks TM
1 Board 28135
LM020L, 2x16
1 LCD1 Parallel LCD 603-00006

Table 2. Components used for the device

The documentation for the NX-1000 board can be found on the CD that board goes along with.

General idea of software algorithm

The flowchart of software algorithm is shown on Figure 3 (pg 13).

The block Start runs once after reset of the board. It contains calls to subroutine for
initializing LCD and 7-segment indicator. After done, control is given to block Main.
The block Main contains main program cycle. It polls switches on every pass; updates
time counter, LCD, blinking LED if corresponding flags are set. The block Main gets control
after every other block is done.
The blocks lSw1Pressed, lSw2Pressed, lSw3Pressed runs when block Main detects
switching on of Switches 1, 2, 3, consequently. The block lSw1Pressed sets flag 'Counting'
and shows '1' on 7-segment indicator. The block lSw2Pressed clears flag 'Counting', shows '2'
on 7-segment indicator,and turns off the blinking LED. The block lSw3Pressed clears flag
'Counting', shows '3' on 7-segment indicator, turns on blinking LED, clears current time, and
updates the LCD (with zero value).
VRED U3 W EDS 01234567 ES D Gren
P15 20 lcdRSP14 19 Timerstopd lcdRWP13 Timerstcoung 18 LEDisOF lcdEP12 LEDgoesONiblnk, 17 lcd7P1 16 SWITCH2 cd6P10l SWITCH31 15 lcd5RESP9 214 B lcd4P8 S OUNDERS 13 7dinATNP2 312 7clkP6 1 sw1237loadRXDP5 10 P4 9 built-n TXDP3 built-n 8 10k LS1 sw3RXP2 10k 27 sw2RTSXP1 16 sw1P0 5 CTS
GND D2 GND GND built-n BS2-IC 510 LED LM02
DOUTIG7 10k 248 ISETDG6 185 DIG5 R6 10 DIG4 3 DIG3 yel-viord 7 VDIG2 4k7 6 DIG1 R3 1 ( DIG0 ( P P 2 1 98 10 ) ) DP 2 (P12) lcdE l G Brn-lkOg c 17 d (P13) lcdRW 7654 F 10k 15 (P14) lcdRS E R4 21 D 23 (P6) 7clkCLK 1320 (P5) 7loadLOADB 1 3214567890 (P7) dinDINA 14
MAX7219 Brn-lkOg

Figure 1. Schematic drawing


Figure 2. Assembled hardware


Figure 3. Flowchart of software algorithm

The purpose of this experiment, the creation of a digital stopwatch, was successfully
accomplished. When button 1 is pressed, the circuit for the pull up switch has zero voltage
across it, hence transmits a logic zero. The pressing of the button is detected by the basic
stamp and a digital signal that corresponds to a “1” is transmitted to the MAX7219 which
controls the LED display by outputting a high to the correct segments of the LED display (in

this case to a, e, and f.) When button “1” is pressed, the program also begins counting. This is
done by counting the number of times that the system runs through the program, which loops
through the code until it detects that another button is pressed. The number of cycles that the
loop runs through is converted to real time by dividing by calibration number, which is the
number of times the loop is completed in 1 sec. This calibration number was measured using
real time and the number of cycles of the loop. The time is transmitted in AscII code to the
LCD display, which is updated every second to show the correct time. When button 2 is
pressed, a “2” is displayed on the LED display and the time stops counting. The last number
outputted before the “2” was pressed remains on the LCD display. Button 3 allows the system
to be reset, by setting all of the counters and the time to zero. Button is also displayed on the
LCD display. All of the buttons have unique frequency sound that is created using the piezo-
In this lab many different components needed to be integrated, including switches, A piezo-
beeper, an LCD display, an LED display, and a microcontroller. In addition, there was a lot of
interfacing that needed to be accomplished. Having unique sounds for each of the buttons
allows the user to easily identify the button that was present. Creating a debugging screen
allows the problems to be understood and fixed if they occur. All of these concepts are
extremely useful and can be built upon to create more functional and complicated systems.

Description of the Code

This section will thoroughly describe the function of the code found in the appendix of
the report. Also included is a block diagram to its basic function found in the schematics
The program begins by assigning the pins of the basic stamp names specific to their
function. Also assigned are constants for LCD functions and MAX 7219 functions. In the midst
of these constants being declared are the declaration of variables dealing with time.
The program begins executing code when it starts by going to subroutines dedicated to
the initialization of the LCD and the 7-segment chip. The LCD initialization sets the LCD in 4
bit mode (takes one nibble of data at a time), clears the screen, then displays a message “Lab
1 – Group B “. The 7 segment initialization sets the seven segment’s intensity, decode mode
setting, etc. It then tests the 7 segment display by outputting high on all segments for 300 ms,
followed by clearing them. Both the LCD and 7 segment display are now ready for use.
In the main loop, many conditions are tested, which determines where the program will
branch. First, all three states of the button are tested. If either of the three buttons are
pressed, the program veers to a separate subroutine which will be described later. The
program then continues to an if statement testing to see whether or not the stop watch is in
fact counting. If the stop watch is counting, another if statement tests to see if the LED should
be off or on. The LED is on for 20 cycles and off for 164 cycles (totaling 184 cycles which is
the amount of cycles calibrated to one second). The blinking counter resets every 184 cycles
in order to repeat the blinking cycle. The program then increments both the blinking counter
(too keep track of the LED) and the temporary time counter. The program then checks to see
whether or not the temporary time counter has reached a calibrated value of how many cycles
of the loop it takes to reach 1 second. This value (as mentioned) was found to be 184 by
measuring the counter value after 5 minutes and comparing them. The stop watch is actually

fast 1 second after about 16 minutes of use. If one second is reached, then the temporary
time is reset to 0 in order to be incremented again. The program in this situation also updates
the LCD screen with an incremented time (this subroutine will also be described later). After
all of this comparing and math completed, the program returns to the beginning to do it all
The subroutine dedicated to the event of switch 3 (reset) being pressed executes the
following tasks. First, the counting variable is set to 0 so the program knows that the
stopwatch is no longer counting. The LED is turned on, and a 3 is sent to the 7 segment digit
(signifying the 3rd switch being pressed). The time variables are all reset to 0, in order to
prime the stop watch to restart. Finally, the Update LCD subroutine is called.
The subroutine dedicated to the event of switch 2 (stop) being pressed executes the following
tasks. First, the counting variable is set to 0, and the LED is turned off. The seven segment is
set to ‘2’ as well. The program then returns to main.
The subroutine dedicated to the event of switch 1 (start timer) being pressed executes the
following tasks. The counter variable is set to 1 allowing the controller to know that the stop
watch has begun counting. The LCD is updated, followed by the LED blinking variable being
reset. The seven segment display is set to 1 and the program returns to main.
The update LCD subroutine is a precursor to the write LCD subroutine. This subroutine first
clears the LCD. It then enters a 4 cycle loop where each cycle takes an individual digit of the
time variable and assigns it (+48 to convert to ASCII) to the character variable. In each of
these cycles the LCD write subroutine is also called, where the program sends 2 the
character variable in 2 nibbles to the LCD.


Overall, our experiment was successful. The stopwatch is fairly accurate and has the ability
to be calibrated. The LED, displays, speaker, and buttons were implemented and worked as
intended. The code functioned correctly with no known bugs.


Jenna – Report: Theoretical background, results

Hardware and Software: Code for LED, timing and buttons, general code structure
Ilya – Report: Schematics, diagrams
Hardware and Software: Wiring of components, initialization code, LCD output
Chris – Report: Problems encountered, code description
Hardware and Software: Wiring of components, initialization code, LCD output
Ian Duncan - Report: Abstract, introduction
Hardware and Software: Code for LED, timing and buttons, general code
Ian Clark – Report: Assembly, editing and formating of the report, testing the device
Hardware and Software: Code for LED, timing and buttons, general code structure


'* @file lab1.bs2

'* @hardware BasicStamp II
'* @lab 1. Digital I/O - Implementing a digital stopwatch
'* @part All
'* @see Schematic: lab1bv3.dsn
'* @date 12 feb 2010
'* @author Team B
'* @desc
' {$STAMP BS2}
' {$PBASIC 2.5}

' Variables and constants

' Pin names

speaker PIN 3
pinSw1 PIN 0
pinSw2 PIN 1
pinSw3 PIN 2
pinLED PIN 15
pin7sData PIN 7 ' after change these values, necessary to change init of 7SEG
pin7sClock PIN 6
pin7sLoad PIN 5
E CON 12 ' LCD Enable pin (1 = enabled)
RS CON 14 ' Register Select (1 = char)
LCDbus VAR OUTC ' 4-bit LCD data bus
msg DATA "LAB 1 - GROUP B "
' ------------------------------------------------------------------------------
' Constants for LCD
' ------------------------------------------------------------------------------
ClrLCD CON $01 ' clear the LCD
CrsrHm CON $02 ' move cursor to home position
'CRSRLF CON $10 ' move cursor left
'CRSRRT CON $14 ' move cursor right
DispLf CON $18 ' shift displayed chars left
DispRt CON $1C ' shift displayed chars right
DDRam CON $80 ' Display Data RAM control

' Temp variables for switches

vSw1 VAR Byte
vSw2 VAR Byte
vSw3 VAR Byte

' Constants for switches

cSwitchDownState CON 0
cNoAutoRepeat CON 255
cAutoRepeatRate CON 0
cStateForBranch CON 1

' Blink parameters

cBlinkingT1 CON 20 ' time for OFF during blinking
cBlinkingT2 CON 184 ' time for ON during blinking

' Variables
vCounting VAR Bit ' 1 - we are counting now
vBlinkingCnt VAR Word ' counter for blinking (look at Blink parameters)
vTimeCnt VAR Word ' counter for time
vTimeCntTmp VAR Word ' temporary counter for time
char VAR Byte ' character sent to LCD
index VAR Byte ' loop counter

' Registers of MAX7219 (LED driver) and constants for it

r7sDecode CON $09 ' bcd decode register
r7sBright CON $0A ' intensity register
r7sScan CON $0B ' scan limit register
r7sShutDn CON $0C ' shutdown register (1 = on)
r7sTest CON $0F ' display test mode

c7sBlankDigit CON %1111 ' blank a digit

c7sOnlyDigit CON 1 ' digit for showing last pushed switch

cTimeCalibration CON 184


DEBUG "Group B", CR, "Lab 1", CR

GOSUB Init7s ' Init of 7-segment indicator

GOSUB InitLCD ' Init of LCD

vCounting = 0

' BUTTON PIN, DownState, Delay, Rate, Workspace, TargetState, Address
BUTTON pinSw3, cSwitchDownState, cNoAutoRepeat, cAutoRepeatRate, vSw3, cStateForBranch,
BUTTON pinSw2, cSwitchDownState, cNoAutoRepeat, cAutoRepeatRate, vSw2, cStateForBranch,

BUTTON pinSw1, cSwitchDownState, cNoAutoRepeat, cAutoRepeatRate, vSw1, cStateForBranch,

IF vCounting = 1 THEN
IF vBlinkingCnt = cBlinkingT1 THEN
ELSEIF vBlinkingCnt = cBlinkingT2 THEN
vBlinkingCnt = -1
vBlinkingCnt = vBlinkingCnt + 1
vTimeCntTmp = vTimeCntTmp + 1
IF vTimeCntTmp = cTimeCalibration THEN
vTimeCnt = vTimeCnt + 1
IF vTimeCnt = 10000 THEN vTimeCnt = 0
vTimeCntTmp = 0



DEBUG "LED is On, Time is reset.",CR
FREQOUT speaker, 250, 1046
vCounting = 0


SHIFTOUT pin7sData, pin7sClock, MSBFIRST, [c7sOnlyDigit, 3]

PULSOUT pin7sLoad,5

vTimeCnt = 0
vTimeCntTmp = 0


DEBUG "LED is Off, Timer is stopped.",CR

FREQOUT speaker, 250, 1318

vCounting = 0


SHIFTOUT pin7sData, pin7sClock, MSBFIRST, [c7sOnlyDigit, 2]

PULSOUT pin7sLoad,5


DEBUG "LED is blinking, Timer is counting.",CR
FREQOUT speaker, 250, 1568
vCounting = 1


vBlinkingCnt = 0


SHIFTOUT pin7sData, pin7sClock, MSBFIRST, [c7sOnlyDigit, 1]

PULSOUT pin7sLoad,5


' Function for initializing LCD.
DIRH = %11111111 ' setup pins for LCD
PAUSE 500 ' let the LCD settle
LCDbus = %0011 ' 8-bit mode
LCDbus = %0010 ' 4-bit mode
char = %00001100 ' disp on, crsr off, blink off
char = %00000110 ' inc crsr, no disp shift

char = ClrLCD ' clear the LCD

FOR index = 0 TO 16
READ index, char ' get character from EE

' Function for updating LCD.
' Current time (in cycles) is in variable vTimeCnt
char = ClrLCD ' clear the LCD
FOR index = 3 TO 0
char = (vTimeCnt DIG index) + 48


' Initialization of 7-segment indicator
DIR5 = 1 ' pins of 7SEG control should be
DIR6 = 1
DIR7 = 1

SHIFTOUT pin7sData, pin7sClock, MSBFIRST, [r7sScan, 0] ' how many digits are displayed (0 -
only one, 7 - all)
PULSOUT pin7sLoad,5 ' lenght of LOAD pulse (from

SHIFTOUT pin7sData, pin7sClock, MSBFIRST, [r7sBright, 5] ' intensity (0 - low, 15 - high)

PULSOUT pin7sLoad,5

SHIFTOUT pin7sData, pin7sClock, MSBFIRST, [r7sDecode, 1] ' Decode-mode for digit 0 (pg.7 of
PULSOUT pin7sLoad,5

SHIFTOUT pin7sData, pin7sClock, MSBFIRST, [r7sShutDn, 1] ' 1 - normal operation, 0 - shutdown

PULSOUT pin7sLoad,5

SHIFTOUT pin7sData, pin7sClock, MSBFIRST, [c7sOnlyDigit, c7sBlankDigit] ' makes all segments off
for future
PULSOUT pin7sLoad,5

SHIFTOUT pin7sData, pin7sClock, MSBFIRST, [r7sTest, 1] ' test - all segments go on for some
PULSOUT pin7sLoad,5


SHIFTOUT pin7sData, pin7sClock, MSBFIRST, [r7sTest, 0] ' test mode goes off, now 7SEG is
ready for use
PULSOUT pin7sLoad,5


' ------------------------------------------------------------------------------
' Subroutines
' ------------------------------------------------------------------------------

LOW RS ' enter command mode

LCDbus = char.HIGHNIB ' output high nibble
PULSOUT E, 1 ' strobe the Enable line
LCDbus = char.LOWNIB ' output low nibble
HIGH RS ' return to character mode