"What's A Microcontroller ?" by Andy Lindsay: Parallax, Inc
"What's A Microcontroller ?" by Andy Lindsay: Parallax, Inc
of
Presentation based on:
Martin A. Hebel
Presentation Index
Use and Copyright
Indicator Lights
The LED as a Light
Voltage and Current
Ohm's Law
The Resistor
LEDs
Breadboard Area
Activity #1 Building and Testing the Light C
ircuit
Continued on next Slide
2
Indicator Lights
Indicator lights are so common to almost
be not noticed.
When a circuit is completed, such as putting an LED in it, a flow exists from one
side to the other. This is called Current.
10
+
-
+
-
+
-
Electrons (-)
+
-
+
-
An atom with an
excess of electrons
has a charge. One
with a deficiency of
electrons has a +
charge.
11
Ohm's Law
Ohms Law states: The amount of
current (I) that will flow is
proportional to the voltage applied
(V), and inversely proportional to the
resistance (R) of the circuit.
I = V/R
As Resistance increases, current
decreases.
13
The Resistor
The resistor is a device used to limit the
amount of current in a circuit. Because it is
so small, color bands are used to identify the
value.
Schematic
Symbol
Part
Drawing
17
LEDs
A Diode is light a one-way check valve in that
current can flow in only one direction. An
LED is a diode that emits light as current is
passed through it (Light Emitting Diode).
Note the connections on the
LED:
Anode: Connected to + side of
voltage. Typically has a longer lead.
Cathode: Connected to side
of voltage. Typically has a
shorter lead AND a flat portion
on the lens.
19
Breadboard Area
A Breadboard is an electrical testing area for
prototyping by quickly connecting
components.
The rows are electrically
connected to make connections
between devices.
Headers are provided
on 2 sides for:
I/O connections to the BASIC
Stamp (P0-P15)
Vdd: + Voltage
Vss: - Voltage
Use of Vin should be used
Vin: Supply Voltage
only as directed as it can
from battery or
damage the BASIC Stamp or
components.
wall transformer
20
21
23
24
25
26
28
Pseudo-Code Example
An example of Pseudo-Code for the LED on/off
program may be:
1.
2.
3.
4.
5.
6.
Start
Turn on LED
Wait for second
Turn off LED
Wait for second
Go back to start
Flowcharts
Flowcharts use symbols to represent the type of
action that is taking place at each step of a
program, and graphically illustrate the flow.
Oval - Start/Stop: Beginning or end of a
program or routine.
Rectangle - Process: Indicates a process
being performed that is internal to the
controller/ computer.
Parallelogram Input/Output: Indicates
reading an input or controlling an output.
Diamond Decision: The state of a condition
is checked, and execution branches to 1 of 2
directions based on the result True or False.
31
Start
LED On
Wait 0.5
Seconds
LED Off
Wait 0.5
Seconds
32
33
35
36
Start
Begin count at 1
Turn LED On
Pause second
Turn LED off
Pause second
Increment count
Count < 10?
Start
Counter = 1
LED On
Wait 0.5 Sec
LED Off
Wait 0.5 Sec
9. End
Program
The diamond
decision symbol evaluates
Counter and flow branches one of two
directions based on the result.
Add 1 to
Counter
True
Counter
<= 10
False
End
37
Initialized
Updated
Checked
What is the value of
Counter when the loop
38
39
Variables
Variables are named locations in RAM memory that
hold data values. The general format for defining
a variable is: Name VAR Type
The name you select should be representative of what
the variable holds and has the following
limitations:
1. Cannot be a word used by PBASIC, such as END or
LOOP.
2. Cannot contain spaces.
3. May contain numbers or underscores, but cannot
start with those.
4. Must be less than 33 characters long.
By convention, variables start with upper-case for
each word in it. Examples:
MyValue, ValueIn, Left_Drive
41
Value Range
Bit
0 to 1
0 to 255
Word
0 to 65535
42
Pups_In_Litter
VAR
Nib
44
45
46
47
By using 2 I/O
Pins and
defining which
is Vss (LOW)
and which is
Vdd (HIGH)
the direction
of current flow
can be
controlled.
48
49
Chapter 2 Review
Why are LEDs are popular choices as indicator
lights.
In what direction can current flow in an LED?
What defines the amount of current that can
flow in a circuit?
What is the purpose of a resistor?
BASIC Stamp I/O pins can act as ___ or __ to
control devices.
How many times will a simple DO-LOOP
repeat?
What are 2 examples of conditional loops?
___________ and _________ are programming
tools for code development.
What a variables, and what sizes can they be?
50
Links
BASIC Stamp Home
Stamps In Class Home
BASIC Stamp Software
BASIC Stamp Robots
BASIC Stamp Yahoo Group
Stamps In Class Yahoo Group
SIUC EST Degree
51