Basic Stamp Programming and Interfacing Examples. BASIC Stamp will be used for illustration. Many pre-defined functions Cost-point: $34-$99 Starter kit for $149. BSII Carrier Board. First LED circuit. Schematic. Experiment #1’ electrical diagram.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Schematic. Experiment #1’ electrical diagram
This is how circuit looks like when you physically build it. The flat side of the LED is closest to the resistor
output 0 ’make PO an output
reblink: ‘ this is where the loop begins
out0 = 0 ‘ turn on the LED
pause 1000 ‘ wait for 1 second, with the LED on
out0 = 1 ‘ now turn off the LED
pause 1000 ‘ leave the LED off for 1 second
goto reblink ‘ go back, and blink the LED again
High school students, attention deficit disorder (ADD), what have been done.
When PO is “low” and current flows, the LED is on.
LED off. When PO is “high” there is no current flow
The horizontal black lines show how the
“sockets” are connected underneath the
This means you don’t have to plug two wires into one socket since thesocket to the right or left is connected.
I/O Pin connections are along left
power connections are along the top
“Vdd” is +5 volts
“Vss” is ground
1) detect ON/OFF(switches)
2) determine resistance using a resistor/capacitor timing circuit (RCTime)
3) read the frequency of a pulse given off by a device or circuit (PulseIn)
4) use analog to digital converter (A/D) to convert voltage value to number understood by micro-controller
To I/O pin
To I/O pin
RCTIME pin, state, resultVariable
Count time while pin remains in state — usually to measure the charge/
discharge time of resistor/capacitor (RC) circuit.
is a variable/constant (0–15) that specifies the I/O pin to use.
This pin will be placed into input mode and left in that state when
the instruction finishes.
is a variable or constant (1 or 0) that will end the RCtime
is a variable in which the time measurement (0 to
65535 in 2µs units) will be stored.
‘ this is a comment
foo var byte
foo = foo + 1
Goto, gosub, return
Ins and Outs (pins)
You should try to save memory by using the smallest size variable necessary to hold your values
Here are some examples of variable declarations using VAR:
‘ Declare variables.
mouse var bit ‘ Value can be 0 or 1.
cat var nib ‘ Value in range 0 to 15.
dog var byte ‘ Value in range 0 to 255.
rhino var word ‘ Value in range 0 to 65535.
‘ Declare constants.
cheers con 3
SERIN Serial input
SEROUT Send data serially (for instance can be used for MIDI output)
RCTIME Measure an RC charge/discharge time.
PULSIN To measure pulse-width of incoming signals; useful for some commercial sensors with built-in A/Ds.
y = yoffset
\'debug "x1 ",DEC x," y1 ",DEC y, cr
if x < 127 then xmax_ok
if y < 127 then ymax_ok
debug "x ",DEC x," y ",DEC y, cr
x var word
y var word
yoffset con 0
yscale con 1
xoffset con 0
xscale con 1
if x > xoffset then xoff_ok
if y > yoffset then yoff_ok
IF...THEN Compare and conditionally branch.
BRANCH Branch to address specified by offset.
GOTO Branch to address.
Branch to subroutine at address. GOSUBs may be
nested up to four levels deep, and you may have
up to 255 GOSUBs in your program.
RETURN Return from subroutine.
FOR...NEXT Establish a FOR-NEXT loop.
\' Useful variables constants for MIDI
controller con 176
number var byte
value var byte
channel var nib
serout 15, 12, 0, [controller + channel, number, value]
When you want your Basic Stamp to do something depending on something else then you will want to use the IF statement.
Unfortunately the Stamp\'s IF statements don\'t work just like most languages where the stuff you want to happen comes in the next line. Instead the IF statement sends the program to label if the condition is met.
You can label any part of your program just by putting the label name followed by a colon.
The if statement test the statement after the if, and when that is true your program jumps to the label specified.
INPUT 3 \'make pin3 and input
IF IN3 = 1 THEN FLASH
1. Analyze our Basic Stamps programs for movement of hexapods and wheeled robots (they are available from lab assistant)
2. Write their small modifications and analyze changes in behavior of the respective robots.
3. Write Basic Stamp programs for the following robots: head, arm, mobile wheeled robot for soccer, walker (hexapod) for soccer.
They should be able to turn right, left, back, and have various “gaits”.
4. Observe that “gaits” are also possible for wheeled robots, video of Japanese dolls from NEC, with their funny way of wheeling in little steps.