28123 Parallax Inc, 28123 Datasheet - Page 220

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
How LightMeter.bs2 Works
The first two lines of the program declare variables. It doesn’t matter whether these
variables are used in subroutines or the main routine, it’s always best to declare variables
(and constants) at the beginning of your program. Since this is such a common practice,
this section of code has a name, variable declarations. This name is shown in the
comment to the right of the first variable declaration.
Many programs also have things that need to get done once at the beginning of the
program. Setting all the 7-segment I/O pins low and then making them outputs is an
example. This section of a PBASIC program also has a name, initialization.
This next segment of code is called the main routine. The main routine calls the
Get_Rc_Time
the
subroutines as fast as it can, over and over again.
All subroutines are usually placed after the main routine. The first subroutine’s name is
Get_Rc_Time:
subroutine has a
command is small because it only needs to pause long enough to make sure the capacitor
is charged. Note that the
variable will be used by the second subroutine.
Update_Display
index VAR Nib
time
OUTH = %00000000
DIRH = %11111111
DO
LOOP
Get_Rc_Time:
GOSUB Get_Rc_Time
GOSUB Delay
GOSUB Update_Display
HIGH 2
PAUSE 3
RCTIME 2, 1, time
subroutine first. Then, it calls the
, and it takes the RC-time measurement on the photoresistor circuit. This
VAR Word
PAUSE
subroutine. Keep in mind that the program goes through the three
command that charges up the capacitor. The
RCTIME
command sets the value of the
' Variable declarations.
' Initialize 7-segment display.
' Main routine.
' RC-time subroutine
' Subroutines
Delay
subroutine, and after that, it calls
time
Duration
variable. This
of this

Related parts for 28123