28123 Parallax Inc, 28123 Datasheet - Page 218

TEXT WHAT'S A MICROCONTROLLER

28123

Manufacturer Part Number
28123
Description
TEXT WHAT'S A MICROCONTROLLER
Manufacturer
Parallax Inc
Type
Programmingr
Datasheet

Specifications of 28123

Style
Book
Title
What's a Microcontroller?
Contents
Whats a Microcontroller? Text
Product
Microcontroller Accessories
Core Processor
PIC16C57c
Flash
128 Bytes
Operating Supply Voltage
9 V
Board Size
31 mm x 16 mm
Lead Free Status / RoHS Status
Not applicable / Not applicable
You can also call one subroutine from within another. This is called nesting subroutines.
Light Meter Using Subroutines
The segments on the display cycle in a circular pattern that gets faster when the light on
the photoresistor gets brighter.
displayed by the 7-segment LED display goes slower.
The program that runs the light meter will deal with three different operations:
Each operation is contained within its own subroutine, and the main
cycle and call each one in sequence, over and over again.
Example Program: LightMeter.bs2
1. Read the photoresistor.
2. Calculate how long to wait before updating the 7-segment LED display.
3. Update the 7-segment LED display.
Make any necessary adjustments to the
looks right with all three subroutines.
Try moving the
subroutines, and see how it works.
Enter and run LightMeter.bs2.
Verify that the circular pattern displayed by the 7-segment LED display is
controlled by the lighting conditions the photoresistor is sensing. Do this by
casting a shadow over it with your hand or a piece of paper.
When nesting subroutines the rule is no more than four deep. See the BASIC Stamp
Manual for more details. Look up
Controlled lighting conditions make a big difference. For best results, conduct this test in
a room lit by fluorescent lights with no direct sunlight (close the blinds). For information on
how to calibrate this meter to other lighting conditions, see the Your Turn section.
GOSUB
When the light gets dimmer, the circular pattern
that calls
GOSUB
and
Subroutine_Name
RETURN
DEBUG
.
commands so that the display
into one of the other
DO…LOOP
routine will

Related parts for 28123