Initial commit after migrating repo and assuring the product launches
This commit is contained in:
@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>AUXIO / MAINIO / IOTERM Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>AUXIO / MAINIO / IOTERM Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p class="PlainText">
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax:<a href="../Commands/AUXIO.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">AUXIO</a>, <a href="../Commands/MAINIO.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">MAINIO</a>, <a href="../Commands/IOTERM.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">IOTERM</a></p>
|
||||
<p class="PlainText"> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p class="PlainText">Note: This program was written for the BS2p but can also run on the BS2pe or BS2px with a change of the $STAMP directive, however, its effects can only be seen on the BS2p40.</p><pre class="BScode" xml:space="preserve">
|
||||
' AUX_MAIN_TERM.BSP
|
||||
' This program demonstrates the use of the AUXIO, MAINIO AND IOTERM
|
||||
' commands to affect I/O pins in the auxiliary and main I/O groups.
|
||||
|
||||
' {$STAMP BS2p}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
#SELECT $STAMP
|
||||
#CASE BS2, BS2E, BS2SX
|
||||
#ERROR "Program requires BS2p40"
|
||||
#CASE BS2P, BS2PE, BS2PX
|
||||
DEBUG "Note: This program designed for the BS2p40", CR
|
||||
#ENDSELECT
|
||||
|
||||
port VAR Bit
|
||||
|
||||
|
||||
Main:
|
||||
DO
|
||||
MAINIO ' Switch to main I/O pins
|
||||
TOGGLE 0 ' Toggle state of I/O pin P0
|
||||
PWM 1, 100, 40 ' Generate PWM on I/O pin P1
|
||||
|
||||
AUXIO ' Switch to auxiliary I/O pins
|
||||
TOGGLE 0 ' Toggle state of I/O pin P0
|
||||
PULSOUT 1, 1000 ' Generate a pulse on I/O pin P1
|
||||
PWM 2, 100, 40 ' Generate PWM on I/O pin P2
|
||||
|
||||
IOTERM port ' Switch to main or aux I/Os
|
||||
' -- depending on port
|
||||
TOGGLE 3 ' Toggle state of I/O pin P3
|
||||
' -- on main and aux, alternately
|
||||
port = ~port ' Invert port
|
||||
PAUSE 1000 ' 1 second delay
|
||||
LOOP
|
||||
END </pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>BRANCH Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>BRANCH Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/BRANCH.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">BRANCH</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p><pre class="BScode" xml:space="preserve">' BRANCH.BS1
|
||||
' This program shows how the value of idx controls the destination of the
|
||||
' BRANCH instruction.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL idx = B2
|
||||
|
||||
|
||||
Main:
|
||||
DEBUG "idx: ", #idx, " "
|
||||
BRANCH idx, (Task_0, Task_1, Task_2) ' branch to task
|
||||
DEBUG "BRANCH target error..." ' ... unless out of range
|
||||
DEUBG CR, CR
|
||||
|
||||
Next_Task:
|
||||
idx = idx + 1 // 4 ' force idx to be 0..3
|
||||
GOTO Main
|
||||
|
||||
Task_0:
|
||||
DEBUG "BRANCHed to Task_0", CR
|
||||
GOTO Next_Task
|
||||
|
||||
Task_1:
|
||||
DEBUG "BRANCHed to Task_1", CR
|
||||
GOTO Next_Task
|
||||
|
||||
Task_2:
|
||||
DEBUG "BRANCHed to Task_2", CR
|
||||
GOTO Next_Task
|
||||
</pre>
|
||||
<p class="PlainText"> </p><pre class="BScode" xml:space="preserve">
|
||||
' BRANCH.BS2
|
||||
' This program shows how the value of idx controls the destination of the
|
||||
' BRANCH instruction.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
idx VAR Nib
|
||||
|
||||
|
||||
Main:
|
||||
DEBUG "idx: ", DEC1 idx, " "
|
||||
BRANCH idx, [Task_0, Task_1, Task_2] ' branch to task
|
||||
DEBUG "BRANCH target error...", ' ... unless out of range
|
||||
CR, CR
|
||||
|
||||
Next_Task:
|
||||
idx = idx + 1 // 4 ' force idx to be 0..3
|
||||
PAUSE 250
|
||||
GOTO Main
|
||||
|
||||
Task_0:
|
||||
DEBUG "BRANCHed to Task_0", CR
|
||||
GOTO Next_Task
|
||||
|
||||
Task_1:
|
||||
DEBUG "BRANCHed to Task_1", CR
|
||||
GOTO Next_Task
|
||||
|
||||
Task_2:
|
||||
DEBUG "BRANCHed to Task_2", CR
|
||||
GOTO Next_Task
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,121 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>BUTTON Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>BUTTON Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/BUTTON.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">BUTTON</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p><pre class="BScode" xml:space="preserve">' BUTTON.BS1
|
||||
' Connect an active-low circuit to pin P0 of the BS1. When you press the
|
||||
' button, the DEBUG screen will display an asterisk (*). The program, as
|
||||
' shown below, will print an asterisk at the first button press, then
|
||||
' delay approximately one second (200 x 5 ms PAUSE) before auto-repeating
|
||||
' at a rate of approximately 100 ms (5 x 20 ms). Feel free to modify the
|
||||
' program to see the effects of your changes on the way BUTTON responds.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL Btn = 0
|
||||
|
||||
SYMBOL btnWrk = B2
|
||||
|
||||
|
||||
Main:
|
||||
' Try changing the Delay value (255) in BUTTON to see the effect of
|
||||
' its modes: 0 = no delay; 1-254 = varying delays before auto-repeat;
|
||||
' 255 = no auto-repeat (only one action per button press)
|
||||
'
|
||||
' The BUTTON instruction will cause the program to branch to
|
||||
' No_Press unless P0 = 0
|
||||
|
||||
PAUSE 5
|
||||
BUTTON Btn, 0, 200, 20, btnWrk, 0, No_Press
|
||||
DEBUG "*"
|
||||
|
||||
No_Press:
|
||||
GOTO Main
|
||||
</pre>
|
||||
<p class="PlainTextIndent"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' BUTTON.BS2
|
||||
' Connect an active-low circuit to pin P0 of the BS2. When you press the
|
||||
' button, the DEBUG screen will display an asterisk (*). The program, as
|
||||
' shown below, will print an asterisk at the first button press, then
|
||||
' delay approximately one second (200 x 5 ms PAUSE) before auto-repeating
|
||||
' at a rate of approximately 100 ms (5 x 20 ms). Feel free to modify the
|
||||
' program to see the effects of your changes on the way BUTTON responds.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
Btn PIN 0
|
||||
|
||||
btnWrk VAR Byte
|
||||
|
||||
|
||||
Main:
|
||||
' Try changing the Delay value (255) in BUTTON to see the effect of
|
||||
' its modes: 0 = no delay; 1-254 = varying delays before auto-repeat;
|
||||
' 255 = no auto-repeat (only one action per button press)
|
||||
'
|
||||
' The BUTTON instruction will cause the program to branch to
|
||||
' No_Press unless P0 = 0
|
||||
|
||||
PAUSE 5
|
||||
BUTTON Btn, 0, 200, 20, btnWrk, 0, No_Press
|
||||
DEBUG "*"
|
||||
|
||||
No_Press:
|
||||
GOTO Main
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>COMPARE Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>COMPARE Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Sytnax: <a href="../Commands/COMPARE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">COMPARE</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p><pre class="BScode" xml:space="preserve">' COMPARE.BPX
|
||||
' This example demonstrates the use of the COMPARE command.
|
||||
' Connect two variable voltage sources (0 to 5 volts) on I/O pins
|
||||
' P1 and P2 (or a button on each pin connected to ground). Run the
|
||||
' program and watch the Debug Terminal display as you adjust the
|
||||
' variable voltage or press the buttons.
|
||||
|
||||
' {$STAMP BS2px}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
#IF $STAMP <> BS2PX #THEN
|
||||
#ERROR "This program requires a BS2px."
|
||||
#ENDIF
|
||||
|
||||
result VAR Bit
|
||||
|
||||
Setup:
|
||||
' P0 = output, all others = input
|
||||
CONFIGPIN DIRECTION, %0000000000000001
|
||||
' Enable pull-ups on P1 and P2
|
||||
CONFIGPIN PULLUP, %0000000000000110
|
||||
|
||||
DEBUG CLS,
|
||||
"BS2px Comparator Demonstration", CR,
|
||||
"==============================", CR,
|
||||
CR,
|
||||
"Input Voltage: P1 > P2", CR,
|
||||
"Output State: P0 = 0"
|
||||
|
||||
Main:
|
||||
DO ' Display P1/P2 comparison
|
||||
COMPARE 1, result
|
||||
IF (result = 0) THEN
|
||||
DEBUG CRSRXY, 18, 3, ">"
|
||||
ELSE
|
||||
DEBUG CRSRXY, 18, 3, "<"
|
||||
ENDIF
|
||||
DEBUG CRSRXY, 19, 4, BIN1 result
|
||||
LOOP</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>CONFIGPIN Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>CONFIGPIN Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/CONFIGPIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">CONFIGPIN</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p><pre class="BScode" xml:space="preserve">' CONFIGPIN.BPX
|
||||
' This example demonstrates the use of the CONFIGPIN command.
|
||||
' All I/O pins are set to inputs with various combinations of
|
||||
' Pull-Up Resistor, Logic Threshold and Schmitt-Trigger properties.
|
||||
' While running, this program will constantly display the state of all
|
||||
' input pins along with an indication of the configuration for each group
|
||||
' of pins. Try connecting different input signals to the I/O pins (such as
|
||||
' buttons, a function generator with a slowing sweeping signal (0 to 5
|
||||
' VDC)) or simply running your fingers across the I/O pins and note how
|
||||
' they react based upon their configured property.
|
||||
|
||||
' {$STAMP BS2px}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
#IF $STAMP <> BS2PX #THEN
|
||||
#ERROR "This program requires a BS2px."
|
||||
#ENDIF
|
||||
|
||||
|
||||
Setup:
|
||||
CONFIGPIN DIRECTION, %0000000000000000 ' Set all I/O pins to inputs
|
||||
CONFIGPIN PULLUP, %1111111111110000 ' Enable pull-ups on pins 4 - 15
|
||||
CONFIGPIN THRESHOLD, %0000111100000000 ' Set P8-P11 to CMOS, others TTL
|
||||
CONFIGPIN SCHMITT, %1111000000000000 ' Enable Schmitt-Triggers P12-P15
|
||||
|
||||
DEBUG CLS,
|
||||
" BS2px INPUT PIN CONFIGURATION TEST", CR,
|
||||
"=========================================================", CR,
|
||||
" P15-P12: Pull-Up Resistors, TTL & Schmitt-Triggers ", CR,
|
||||
" / ", CR,
|
||||
" / P11-P8: Pull-Up Resistors & CMOS ", CR,
|
||||
" / / ", CR,
|
||||
" | / P7-P4: Pull-Up Resistors & TTL ", CR,
|
||||
" | | / ", CR,
|
||||
" | | | P3-P0: Normal ", CR,
|
||||
" | | | / ", CR,
|
||||
" | | | | ", CR,
|
||||
"---- ---- ---- ---- "
|
||||
Main:
|
||||
DO
|
||||
' Display input pin states
|
||||
DEBUG CRSRXY, 0, 12 ,
|
||||
BIN4 IND, " ", BIN4 INC, " ", BIN4 INB, " ", BIN4 INA
|
||||
LOOP
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>COUNT Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>COUNT Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/COUNT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">COUNT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' COUNT.BS2
|
||||
' Connect an active-low button circuit shown to pin P0 of the BS2. The
|
||||
' DEBUG screen will prompt you to press the button as quickly as possible
|
||||
' for a 1-second count. When the count is done, the screen will display
|
||||
' your "score," the total number of cycles registered by COUNT. Note that
|
||||
' this score will almost always be greater than the actual number of presses
|
||||
' because of switch contact bounce.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
PushBtn PIN 0 ' pushbutton on P0
|
||||
|
||||
#SELECT $STAMP
|
||||
#CASE BS2, BS2E
|
||||
DurAdj CON $100 ' / 1
|
||||
#CASE BS2SX
|
||||
DurAdj CON $280 ' / 0.400
|
||||
#CASE BS2P, BS2PX
|
||||
OneSec CON $37B ' / 0.287
|
||||
#CASE BS2PE
|
||||
OneSec CON $163 ' / 0.720
|
||||
#ENDSELECT
|
||||
|
||||
Capture CON 1000 ' 1 second
|
||||
|
||||
cycles VAR Word ' counted cycles
|
||||
|
||||
|
||||
Main:
|
||||
DO
|
||||
DEBUG CLS,
|
||||
"How many times can you press the button in 1 second?", CR
|
||||
PAUSE 1000
|
||||
DEBUG "Ready, set... "
|
||||
PAUSE 500
|
||||
DEBUG "GO!", CR
|
||||
COUNT PushBtn, (Capture */ DurAdj), cycles
|
||||
DEBUG CR, "Your score: ", DEC cycles, CR
|
||||
PAUSE 3000
|
||||
DEBUG "Press button to go again."
|
||||
DO : LOOP UNTIL (PushBtn = 0) ' wait for button press
|
||||
LOOP
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>DATA Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>DATA Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/DATA.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DATA</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' DATA.BS2
|
||||
' This program stores a number of large text strings into EEPROM with the
|
||||
' DATA directive and then sends them, one character at a time via the DEBUG
|
||||
' command. This is a good demonstration of how to save program space by
|
||||
' storing large amounts of data in EEPROM directly, rather than embedding
|
||||
' the data into DEBUG commands.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
idx VAR Word ' current location number
|
||||
phrase VAR Nib ' current phrase number
|
||||
char VAR Byte ' character to print
|
||||
|
||||
' ----- Define all text phrases (out of order, just for fun!) -----
|
||||
'
|
||||
Text1 DATA "Here is the first part of a large chunk of textual "
|
||||
DATA "data ", CR, "that needs to be transmitted. There's "
|
||||
DATA "a 5 second delay", CR, "between text paragraphs. ", CR
|
||||
DATA CR, 0
|
||||
|
||||
Text3 DATA "The alternative (having multiple DEBUGs or SEROUTs, "
|
||||
DATA "each ", CR, "with their own line of text) consumes "
|
||||
DATA "MUCH more EEPROM ", CR, "(program) space. ", CR
|
||||
DATA CR, 0
|
||||
|
||||
Text6 DATA "The 255 is used by this program to indicate we've "
|
||||
DATA "reached the ", CR, "End of Text. The Main routine "
|
||||
DATA "pauses in between each block of ", CR, "text, and then "
|
||||
DATA "uses a LOOKUP command TO retrieve the location ", CR
|
||||
DATA "of the next desired block of text to print. ", 0
|
||||
|
||||
Text4 DATA CLS, "This program also demonstrates retrieving data "
|
||||
DATA "out of order ", CR, "in relation TO the way it is "
|
||||
DATA "stored in EEPROM. Additionally, ", CR, "control codes "
|
||||
DATA "(like carriage-returns, clear-screens, etc) can ", CR
|
||||
DATA "be embedded right in the data, as it is here. ", CR
|
||||
DATA CR, 0
|
||||
|
||||
Text2 DATA "This is an example of a good way to save space in "
|
||||
DATA "your ", CR, "BASIC Stamp's program by storing data "
|
||||
DATA "into EEPROM and ", CR, "retrieving it, one byte at a "
|
||||
DATA "time, and transmitting it ", CR, "with just a single "
|
||||
DATA "DEBUG (or SEROUT) command.", CR, CR, 0
|
||||
|
||||
Text5 DATA "The Print_It routine simply takes the Index variable, "
|
||||
DATA "retrieves ", CR, "the character at the EEPROM location "
|
||||
DATA "pointed to by it, and ", CR, "prints it to the screen "
|
||||
DATA "unti it finds a byte with a value of 255.", CR, CR, 0
|
||||
|
||||
|
||||
Main:
|
||||
DEBUG CLS ' Clear DEBUG window
|
||||
FOR phrase = 1 TO 6 ' Print blocks one by one
|
||||
LOOKUP (phrase - 1),
|
||||
[Text1, Text2, Text3, Text4, Text5, Text6], idx
|
||||
GOSUB Print_It
|
||||
PAUSE 5000 ' Pause for 5 seconds
|
||||
NEXT
|
||||
END
|
||||
|
||||
Print_It:
|
||||
DO
|
||||
READ idx, char ' Get next character
|
||||
idx = idx + 1 ' Point to next location
|
||||
IF (char = 0) THEN EXIT ' If 0, we're done with block
|
||||
DEBUG char ' Otherwise, transmit it
|
||||
LOOP
|
||||
RETURN ' Return to the main routine
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>DEBUG / DEBUGIN Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>DEBUG / DEBUGIN Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" /><span class="code_in_text"> {PBASIC 2.5}</span>
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/DEBUG.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DEBUG</a>, <a href="../Commands/DEBUGIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DEBUGIN</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' DEBUG_DEBUGIN.BS2
|
||||
' This program demonstrates the ability to accept user input from the
|
||||
' Debug Terminal, and to accept numeric entry in any valid format.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
myNum VAR Word
|
||||
|
||||
|
||||
Main:
|
||||
DO
|
||||
DEBUG CLS, "Enter any number: " ' prompt user
|
||||
DEBUGIN SNUM myNum ' accept number in any format
|
||||
|
||||
DEBUG CRSRXY, 0, 2, ' display in all formats
|
||||
SDEC ? myNum,
|
||||
SHEX ? myNum,
|
||||
SBIN ? myNum
|
||||
PAUSE 3000
|
||||
LOOP ' do it again
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>DEBUG Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>DEBUG Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/DEBUG.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DEBUG</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p><pre class="BScode" xml:space="preserve">' DEBUG.BAS
|
||||
' Demonstrates the use of the BS1 DEBUG instruction. The BS1 DEBUG defaults
|
||||
' to decimal output and provides the name of the variable unless directed
|
||||
' otherwise.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL addr = B2 ' EEPROM address
|
||||
SYMBOL char = B3 ' character to print
|
||||
|
||||
Messages:
|
||||
EEPROM ("The Parallax BASIC Stamp 1", 13, 0)
|
||||
|
||||
|
||||
Main:
|
||||
char = "A"
|
||||
|
||||
DEBUG CLS ' clear screen
|
||||
DEBUG char, CR ' standard decimal output
|
||||
DEBUG $char, CR ' hex ($)
|
||||
DEBUG %char, CR ' binary (%)
|
||||
DEBUG #char, CR ' value only (#)
|
||||
DEBUG "Your grade is: " ' string
|
||||
DEBUG #@char, CR, CR ' value only, as ASCII (@)
|
||||
|
||||
addr = 0 ' point to message
|
||||
GOSUB Print_It
|
||||
DEBUG "The Parallax BASIC Stamp 1" ' same message -- fast
|
||||
|
||||
END
|
||||
|
||||
' This subroutine can be used to transmit a string stored in EEPROM to
|
||||
' the DEBUG window. Note that this is very SLOW as for each character the
|
||||
' entire DEBUG packet (97 bytes!) must be transmitted -- which means that
|
||||
' you can transmit about five characters per second with this method.
|
||||
'
|
||||
' A better alternative to this subroutine is to BRANCH to DEBUG statements
|
||||
' containing the entire string.
|
||||
|
||||
Print_It:
|
||||
READ addr, char ' get character from EEPROM
|
||||
addr = addr + 1 ' point to next location
|
||||
IF char = 0 THEN Print_Done ' if 0, terminate printing
|
||||
DEBUG #@char ' character to DEBUG window
|
||||
GOTO Print_It ' loop again
|
||||
|
||||
Print_Done:
|
||||
RETURN
|
||||
</pre>
|
||||
<p class="PlainText"> </p>
|
||||
<p class="PlainText">This next demonstration illustrates sending information to and retrieving information from the Debug Terminal window. Also illustrated is the unique ability to accept any valid numeric format using the NUM modifier. To enter binary or hexadecimal values, the number must be preceded by "%" (binary) or "$" (hex).</p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' DEBUG_DEBUGIN.BS2
|
||||
' This program demonstrates the ability to accept user input from the
|
||||
' Debug Terminal, and to accept numeric entry in any valid format.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
myNum VAR Word
|
||||
|
||||
|
||||
Main:
|
||||
DO
|
||||
DEBUG CLS, "Enter a any number: " ' prompt user
|
||||
DEBUGIN SNUM myNum ' accept number in any format
|
||||
|
||||
DEBUG CRSRXY, 0, 2, ' display in all formats
|
||||
SDEC ? myNum,
|
||||
SHEX ? myNum,
|
||||
SBIN ? myNum
|
||||
PAUSE 3000
|
||||
LOOP ' do it again
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>DO...LOOP Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>DO...LOOP Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" /><span class="code_in_text"> {PBASIC 2.5}</span>
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/DO_LOOP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DO…LOOP</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' DO-LOOP.BS2
|
||||
' This program creates a little guessing game. It starts by creating
|
||||
' a (psuedo) random number between 1 and 10. The inner loop will run
|
||||
' until the answer is guessed or 10 tries have been attempted. The
|
||||
' outer loop has no condition and will cause the inner loop code to
|
||||
' run until the BASIC Stamp is reprogrammed.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
rVal VAR Word ' random value
|
||||
answer VAR Byte ' game answer
|
||||
guess VAR Byte ' player guess
|
||||
tries VAR Nib ' number of tries
|
||||
|
||||
|
||||
Main:
|
||||
DO
|
||||
RANDOM rVal
|
||||
answer = rVal.LOWBYTE */ 10 + 1 ' create 1 - 10 answer
|
||||
tries = 0
|
||||
|
||||
DO ' get answer until out of tries
|
||||
DEBUG CLS,
|
||||
"Guess an number (1 - 10): ",
|
||||
CLREOL
|
||||
DEBUGIN DEC guess ' get new guess
|
||||
tries = tries + 1 ' update tries count
|
||||
LOOP UNTIL ((tries = 10) OR (guess = answer))
|
||||
|
||||
IF (guess = answer) THEN ' test reason for loop end
|
||||
DEBUG CR, "You got it!"
|
||||
ELSE
|
||||
DEBUG CR, "Sorry ... the answer was ", DEC answer, "."
|
||||
ENDIF
|
||||
PAUSE 1000
|
||||
LOOP ' run again
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,115 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>DTMFOUT Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>DTMFOUT Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/DTMFOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DTMFOUT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve"> DTMFOUT.BS2
|
||||
' This demo program is a rudimentary memory dialer. Since DTMF digits fit
|
||||
' within a nibble (four bits), the program below packs two DTMF digits into
|
||||
' each byte of three EEPROM data tables. The end of a phone number is marked
|
||||
' by the nibble $F, since this is not a valid phone-dialing digit.
|
||||
' Conditional compilation sets the timing adjustment factor so that the
|
||||
' output will sound the same on any BS2 module.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
Spkr PIN 10 ' DTMF output on pin 10
|
||||
|
||||
#SELECT $STAMP
|
||||
#CASE BS2, BS2E, BS2PE
|
||||
TmAdj CON $100 ' x 1.0 (time adjust)
|
||||
#CASE BS2SX
|
||||
TmAdj CON $280 ' x 2.5
|
||||
#CASE BS2P
|
||||
TmAdj CON $3C5 ' x 3.77
|
||||
#CASE BS2PX
|
||||
TmAdj CON $605 ' x 6.02
|
||||
#ENDSELECT
|
||||
|
||||
eeLoc VAR Byte ' EEPROM address of stored number
|
||||
eeByte VAR Byte ' Byte containing two DTMF digits
|
||||
dtDig VAR eeByte.NIB1 ' Digit to dial
|
||||
phone VAR Nib ' Pick a phone #
|
||||
hiLo VAR Bit ' Bit to select upper and lower nib
|
||||
|
||||
Parallax DATA $19,$16,$62,$48,$33,$3F ' Phone: 1-916-624-8333
|
||||
ParallaxFax DATA $19,$16,$62,$48,$00,$3F ' Phone: 1-916-624-8003
|
||||
Information DATA $15,$20,$55,$51,$21,$2F ' Phone: 1-520-555-1212
|
||||
|
||||
|
||||
Main:
|
||||
FOR phone = 0 TO 2
|
||||
' retrieve address
|
||||
LOOKUP phone, [Parallax, ParallaxFax, Information], eeLoc
|
||||
GOSUB Dial_Number
|
||||
PAUSE 2000
|
||||
NEXT
|
||||
END
|
||||
|
||||
Dial_Number:
|
||||
DO
|
||||
READ eeLoc, eeByte ' Retrieve byte from EEPROM
|
||||
eeLoc = eeLoc + 1 ' point to next pair of digits
|
||||
FOR hiLo = 0 TO 1 ' Dial upper and lower digits
|
||||
IF (dtDig = $F) THEN EXIT ' Hex $F is end-of-number flag
|
||||
DTMFOUT Spkr, ' dial digit
|
||||
150 */ TmAdj, 25, [dtDig] ' 150 ms on, 25 ms off
|
||||
eeByte = eeByte << 4 ' Shift in next digit
|
||||
NEXT
|
||||
LOOP UNTIL (dtDig = $F)
|
||||
RETURN
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>EEPROM Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>EEPROM Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" /><span class="code_in_text"> {PBASIC 1.0}</span>
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/EEPROM.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">EEPROM</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p><pre class="BScode" xml:space="preserve">' EEPROM.BS1
|
||||
' This program stores a couple of text strings into EEPROM with the EEPROM
|
||||
' directive and then sends them, one character at a time via the SEROUT
|
||||
' command. This is a good demonstration of how to save program space by
|
||||
' storing large amounts of data in EEPROM directly, rather than embedding
|
||||
' the data into SEROUT commands.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL SOut = 0 ' serial output
|
||||
|
||||
SYMBOL idx = B2 ' Holds current location number
|
||||
SYMBOL phrase = B3
|
||||
SYMBOL char = B4 ' Holds current character to print
|
||||
|
||||
Phrases:
|
||||
EEPROM ("Here is a long message that needs to be transmitted.", 13, 0)
|
||||
EEPROM ("Here is some more text to be transmitted.", 13, 0)
|
||||
|
||||
|
||||
Main:
|
||||
idx = 0
|
||||
FOR phrase = 1 TO 2 ' select phrase
|
||||
GOSUB Print_It ' print the phrase
|
||||
PAUSE 3000 ' Pause for 3 seconds
|
||||
NEXT
|
||||
END
|
||||
|
||||
Print_It:
|
||||
READ idx, char ' get next character
|
||||
idx = idx + 1 ' point to next EEPROM location
|
||||
IF char = 0 THEN Print_Done ' if 0, we're done with this block
|
||||
SEROUT SOut, N2400, (char) ' otherwise, transmit it
|
||||
'DEBUG #@char ' -- for demo with DEBUG (slower)
|
||||
GOTO Print_It
|
||||
|
||||
Print_Done:
|
||||
RETURN ' return to caller</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>EXIT Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>EXIT Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" /><span class="code_in_text"> {PBASIC 2.5}</span>
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/EXIT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">EXIT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' EXIT.BS2
|
||||
' This program demonstrates the early termination of DO...LOOP and
|
||||
' FOR..NEXT loop structures. IF...THEN is used to test a condition
|
||||
' and when true, EXIT will terminate the loop.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
col VAR Nib
|
||||
row VAR Nib
|
||||
|
||||
|
||||
Setup:
|
||||
col = 0
|
||||
|
||||
Main:
|
||||
DO WHILE (col < 10) ' attempt 10 iterations
|
||||
FOR row = 0 TO 15 ' attempt 16 iterations
|
||||
IF (row > 9) THEN EXIT ' terminate when row > 9
|
||||
DEBUG CRSRXY, (col * 8), row, ' print col/row at location
|
||||
DEC col, "/", DEC row, CR
|
||||
NEXT
|
||||
col = col + 1 ' update column
|
||||
IF (col = 3) THEN EXIT ' terminate when col = 3
|
||||
LOOP
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>FOR...NEXT Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>FOR...NEXT Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/FOR_NEXT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">FOR…NEXT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p><pre class="BScode" xml:space="preserve">' FOR-NEXT.BS1
|
||||
' This example uses a FOR...NEXT loop to churn out a series of sequential
|
||||
' squares (numbers 1, 2, 3, 4... raised to the second power) by using a
|
||||
' variable to set the FOR...NEXT stepValue, and incrementing stepValue within
|
||||
' the loop. Sir Isaac Newton is generally credited with the discovery of
|
||||
' this technique.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL square = B2 ' FOR/NEXT counter
|
||||
SYMBOL stepSize = B3 ' step size, increase by 2 each loop
|
||||
|
||||
|
||||
Setup:
|
||||
stepSize = 1
|
||||
square = 1
|
||||
|
||||
Main:
|
||||
FOR square = 1 TO 250 STEP stepSize ' show squares up to 250
|
||||
DEBUG square ' display on screen
|
||||
stepSize = stepSize + 2 ' add 2 to stepSize
|
||||
NEXT ' loop until square > 250
|
||||
END
|
||||
</pre>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' FOR-NEXT.BS1
|
||||
' This example uses a FOR...NEXT loop to churn out a series of sequential
|
||||
' squares (numbers 1, 2, 3, 4... raised to the second power) by using a
|
||||
' variable to set the FOR...NEXT stepValue, and incrementing stepValue within
|
||||
' the loop. Sir Isaac Newton is generally credited with the discovery of
|
||||
' this technique.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL square = B2 ' FOR/NEXT counter
|
||||
SYMBOL stepSize = B3 ' step size, increase by 2 each loop
|
||||
|
||||
|
||||
Setup:
|
||||
stepSize = 1
|
||||
square = 1
|
||||
|
||||
Main:
|
||||
FOR square = 1 TO 250 STEP stepSize ' show squares up to 250
|
||||
DEBUG square ' display on screen
|
||||
stepSize = stepSize + 2 ' add 2 to stepSize
|
||||
NEXT ' loop until square > 250
|
||||
END</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>FREQOUT Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>FREQOUT Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/FREQOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">FREQOUT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' FREQOUT.BS2
|
||||
' This program demonstrates a sound-effects generation by the BASIC Stamp.
|
||||
' Conditional compilation sets timing and frequency adjustment factors so
|
||||
' that the output will sound the same on any BS2 module.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
Spkr PIN 10 ' output pin for FREQOUT
|
||||
|
||||
#SELECT $STAMP
|
||||
#CASE BS2, BS2E
|
||||
TmAdj CON $100 ' x 1.0 (time adjust)
|
||||
FrAdj CON $100 ' x 1.0 (freq adjust)
|
||||
#CASE BS2SX
|
||||
TmAdj CON $280 ' x 2.5
|
||||
FrAdj CON $066 ' x 0.4
|
||||
#CASE BS2P
|
||||
TmAdj CON $3C5 ' x 3.77
|
||||
FrAdj CON $044 ' x 0.265
|
||||
#CASE BS2PE
|
||||
TmAdj CON $100 ' x 1.0
|
||||
FrAdj CON $0A9 ' x 0.66
|
||||
#CASE BS2PX
|
||||
TmAdj CON $607 ' x 6.02
|
||||
FrAdj CON $02A ' x 0.166
|
||||
#ENDSELECT
|
||||
|
||||
|
||||
Main:
|
||||
DEBUG "Let's make a call...", CR
|
||||
' combine 350 Hz & 440 Hz for dial tone
|
||||
FREQOUT Spkr, 2000 */ TmAdj, 350 */ FrAdj, 440 */ FrAdj
|
||||
' dial number (digits 150 ms on, 25 ms off)
|
||||
DTMFOUT Spkr, 150 */ TmAdj, 25, [5, 5, 5, 1, 2, 1, 2]
|
||||
PAUSE 500
|
||||
|
||||
' bad connection (SIT sequence)
|
||||
FREQOUT Spkr, 375 */ TmAdj, 985 */ FrAdj
|
||||
FREQOUT Spkr, 375 */ TmAdj, 1371 */ FrAdj
|
||||
FREQOUT Spkr, 375 */ TmAdj, 1777 */ FrAdj
|
||||
|
||||
DEBUG "Oops! -- try again...", CR
|
||||
PAUSE 1000
|
||||
DTMFOUT Spkr, 150 */ TmAdj, 25, [5, 5, 5, 2, 2, 2, 2]
|
||||
DEBUG "Ringing"
|
||||
FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj
|
||||
PAUSE 4000
|
||||
FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj
|
||||
INPUT Spkr
|
||||
DEBUG CLS, "Done."
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>GET / PUT Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>GET / PUT Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/GET.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GET</a>, <a href="../Commands/PUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">PUT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: This is written for the BS2sx and will also run on the BS2e, BS2p, BS2pe, and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' GET_PUT1.BSX
|
||||
' This example demonstrates the use of the GET AND PUT commands. First,
|
||||
' slot location is read using GET to display the currently running program
|
||||
' number. Then a set of values are written (PUT) into locations 0 TO 9.
|
||||
' Afterwards, program number 1 is RUN. This program is a BS2SX project
|
||||
' consisting of GET_PUT1.BSX and GET_PUT2.BSX, but will run on the BS2e,
|
||||
' BS2p, BS2pe, and BS2px without modification.
|
||||
|
||||
' {$STAMP BS2sx, GET_PUT2.BSX}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
#SELECT $STAMP
|
||||
#CASE BS2
|
||||
#ERROR "BS2e or greater required."
|
||||
#CASE BS2E, BS2SX
|
||||
Slot CON 63
|
||||
#CASE BS2P, BS2PE, BS2PX
|
||||
Slot CON 127
|
||||
#ENDSELECT
|
||||
|
||||
value VAR Byte
|
||||
idx VAR Byte
|
||||
|
||||
|
||||
Setup:
|
||||
GET Slot, value
|
||||
DEBUG "Program Slot #", DEC value.NIB0, CR
|
||||
|
||||
Main:
|
||||
FOR idx = 0 TO 9
|
||||
value = (idx + 3) * 8
|
||||
PUT idx, value
|
||||
DEBUG " Writing: ", DEC2 value, " to location: ", DEC2 idx, CR
|
||||
NEXT
|
||||
DEBUG CR
|
||||
RUN 1
|
||||
END
|
||||
</pre>
|
||||
<p class="PlainText"> </p><pre class="BScode" xml:space="preserve">' GET_PUT2.BSX
|
||||
' This example demonstrates the use of the GET and PUT commands. First,
|
||||
' the Slot location is read using GET to display the currently running
|
||||
' program number. Then a set of values are read (GET) from locations
|
||||
' 0 to 9 and displayed on the screen for verification. This program is a
|
||||
' BS2SX project consisting of GET_PUT1.BSX and GET_PUT2.BSX, but will run
|
||||
' on the BS2e, BS2p, BS2pe, and BS2px without modification.
|
||||
|
||||
' {$STAMP BS2sx}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
#SELECT $STAMP
|
||||
#CASE BS2
|
||||
#ERROR "BS2e or greater required."
|
||||
#CASE BS2E, BS2SX
|
||||
Slot CON 63
|
||||
#CASE BS2P, BS2PE, BS2PX
|
||||
Slot CON 127
|
||||
#ENDSELECT
|
||||
|
||||
value VAR Byte
|
||||
idx VAR Byte
|
||||
|
||||
|
||||
Setup:
|
||||
GET Slot, value
|
||||
DEBUG "Program Slot #", DEC value.NIB0, CR
|
||||
|
||||
Main:
|
||||
FOR idx = 0 TO 9
|
||||
GET idx, value
|
||||
DEBUG " Reading: ", DEC2 value, " from location: ", DEC2 idx, CR
|
||||
NEXT
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,148 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>GOSUB Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>GOSUB Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/GOSUB.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GOSUB</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p><pre class="BScode" xml:space="preserve">' GOSUB.BS1
|
||||
' This program is a guessing game that generates a random number in a
|
||||
' subroutine called Pick_A_Number. It is written to stop after three
|
||||
' guesses. To see a common bug associated with GOSUB, delete or comment
|
||||
' out the line beginning with END after the FOR-NEXT loop. This means
|
||||
' that after the loop is finished, the program will wander into the
|
||||
' Pick_A_Number subroutine. When the RETURN at the end executes, the
|
||||
' program will go back to the beginning of the program. This will cause
|
||||
' the program to execute endlessly. Make sure that your programs can't
|
||||
' accidentally execute subroutines!
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL rounds = B2 ' number of reps
|
||||
SYMBOL numGen = W0 ' random number holder
|
||||
SYMBOL myNum = B3 ' random number, 1-10
|
||||
|
||||
|
||||
Setup:
|
||||
numGen = 11500 ' initialize random "seed"
|
||||
|
||||
Main:
|
||||
FOR rounds = 1 TO 10
|
||||
DEBUG CLS, "Pick a number from 1 to 10", CR
|
||||
GOSUB Pick_A_Number
|
||||
PAUSE 2000 ' dramatic pause
|
||||
DEBUG "My number was: ", #myNum ' show the number
|
||||
PAUSE 1000 ' another pause.
|
||||
NEXT
|
||||
DEBUG CLS, "Done"
|
||||
END ' end program
|
||||
|
||||
' Random-number subroutine. A subroutine is just a piece of code with
|
||||
' the RETURN instruction at the end. Always make sure your program enters
|
||||
' subroutines with a GOSUB. If you don't, the RETURN won't have the
|
||||
' correct address, and your program will have a bug!
|
||||
|
||||
Pick_A_Number:
|
||||
RANDOM numGen ' stir up the bits of NumGen.
|
||||
DEBUG numGen, CR
|
||||
myNum = numGen / 6550 MIN 1 ' scale to fit 1-10 range.
|
||||
RETURN ' go back to 1st instruction
|
||||
</pre>
|
||||
<p class="PlainText"> <![CDATA[ ]]></p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' GOSUB.BS2
|
||||
' This program is a guessing game that generates a random number in a
|
||||
' subroutine called Pick_A_Number. It is written to stop after three
|
||||
' guesses. To see a common bug associated with GOSUB, delete or comment
|
||||
' out the line beginning with END after the FOR-NEXT loop. This means
|
||||
' that after the loop is finished, the program will wander into the
|
||||
' Pick_A_Number subroutine. When the RETURN at the end executes, the
|
||||
' program will go back to the beginning of the program. This will cause
|
||||
' the program to execute endlessly. Make sure that your programs can't
|
||||
' accidentally execute subroutines!
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
rounds VAR Byte ' number of reps
|
||||
numGen VAR Word ' random number holder
|
||||
myNum VAR Byte ' random number, 1-10
|
||||
|
||||
|
||||
Setup:
|
||||
numGen = 11500 ' initialize random "seed"
|
||||
|
||||
Main:
|
||||
FOR rounds = 1 TO 10
|
||||
DEBUG CLS, "Pick a number from 1 to 10", CR
|
||||
GOSUB Pick_A_Number
|
||||
PAUSE 2000 ' dramatic pause
|
||||
DEBUG "My number was: ", DEC myNum ' show the number
|
||||
PAUSE 1000 ' another pause.
|
||||
NEXT
|
||||
DEBUG CLS, "Done"
|
||||
END ' end program
|
||||
|
||||
' Random-number subroutine. A subroutine is just a piece of code with
|
||||
' the RETURN instruction at the end. Always make sure your program enters
|
||||
' subroutines with a GOSUB. If you don't, the RETURN won't have the
|
||||
' correct address, and your program will have a bug!
|
||||
|
||||
Pick_A_Number:
|
||||
RANDOM numGen ' stir up the bits of NumGen.
|
||||
DEBUG DEC ? numGen
|
||||
myNum = numGen / 6550 MIN 1 ' scale to fit 1-10 range.
|
||||
RETURN ' go back to 1st instruction
|
||||
' after GOSUB that got us here
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>GOTO Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>GOTO Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/GOTO.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GOTO</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: This is written for the BS2 and will run on any BASIC Stamp module. Modify the $STAMP directive (as required) before downloading to the BS1, BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' GOTO.BS2
|
||||
' This program isn't practical at all, but demonstrates the use of GOTO to
|
||||
' jump around the code. This code jumps between three different routines,
|
||||
' each of which print something different on the screen. The routines are
|
||||
' out of order for this example.
|
||||
|
||||
' {$STAMP BS2}
|
||||
|
||||
|
||||
Start:
|
||||
GOTO Routine1
|
||||
|
||||
Routine2:
|
||||
DEBUG "We're in routine #2", CR
|
||||
PAUSE 1000
|
||||
GOTO Routine3
|
||||
|
||||
Routine1:
|
||||
DEBUG "We're in routine #1", CR
|
||||
PAUSE 1000
|
||||
GOTO Routine2
|
||||
|
||||
Routine3:
|
||||
DEBUG "We're in routine #3", CR
|
||||
PAUSE 1000
|
||||
GOTO Routine1</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>HIGH / LOW Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>HIGH / LOW Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/HIGH.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">HIGH</a>, <a href="../Commands/LOW.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LOW</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p>NOTE: This is written for the BS2 and will run on any BASIC Stamp module. Modify the $STAMP directive (as required) before downloading to the BS1, BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' HIGH_LOW.BS2
|
||||
' This simple program sets I/O pin 0 high for 1/2 second and low for
|
||||
' 1/2 second in an endless loop. Connect an LED to P0 for a simple
|
||||
' blinker.
|
||||
|
||||
' {$STAMP BS2}
|
||||
|
||||
|
||||
Main:
|
||||
HIGH 0
|
||||
PAUSE 500
|
||||
LOW 0
|
||||
PAUSE 500
|
||||
GOTO Main
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,118 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>I2CIN / I2COUT Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>I2CIN / I2COUT Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/I2CIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">I2CIN</a>, <a href="../Commands/I2COUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">I2COUT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/24lc16_sch.gif" />
|
||||
</p>
|
||||
<p>NOTE: This is written for the BS2p and will also run on the BS2pe and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2pe or BS2px.</p><pre class="BScode" xml:space="preserve">' I2C.BSP
|
||||
' This program demonstrates writing and reading every location in a 24LC16B
|
||||
' EEPROM using the BS2p/BS2pe.BS2px's I2C commands. Connect the BS2p, BS2pe,
|
||||
' or BS2px to the 24LC16B DIP EEPROM as shown in the diagram in the I2CIN
|
||||
' or I2COUT command description.
|
||||
|
||||
' {$STAMP BS2p}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
#IF ($STAMP < BS2P) #THEN
|
||||
#ERROR "Program requires BS2p, BS2pe, or BS2px."
|
||||
#ENDIF
|
||||
|
||||
SDA PIN 0 ' I2C SDA pin
|
||||
SCL PIN SDA + 1
|
||||
|
||||
addr VAR Word ' internal address
|
||||
block VAR Nib ' block address in 24LC16
|
||||
value VAR Byte ' value to write
|
||||
check VAR Nib ' for checking retuned values
|
||||
result VAR Byte(16) ' array for returned value
|
||||
|
||||
|
||||
Write_To_EEPROM:
|
||||
DEBUG "Writing...", CR
|
||||
PAUSE 2000
|
||||
FOR addr = 0 TO 2047 STEP 16 ' loop through all addresses
|
||||
block = addr.NIB2 << 1 ' calculate block address
|
||||
value = addr >> 4 ' create value from upper 8 bits
|
||||
' write 16 bytes
|
||||
I2COUT SDA, $A0 | block, addr, [REP value\16]
|
||||
PAUSE 5
|
||||
DEBUG "Addr: ", DEC4 addr, "-", DEC4 addr + 15, " ",
|
||||
"Value: ", DEC3 value, CR
|
||||
NEXT
|
||||
PAUSE 2000
|
||||
|
||||
Read_From_EEPROM:
|
||||
DEBUG CR, "Reading...", CR
|
||||
PAUSE 2000
|
||||
FOR addr = 0 TO 2047 STEP 16
|
||||
block = addr.NIB2 << 1
|
||||
value = addr >> 4
|
||||
I2CIN SDA, $A1 | block, addr, [STR result\16]
|
||||
FOR check = 0 TO 15
|
||||
IF (result(check) <> value) THEN Error
|
||||
NEXT
|
||||
DEBUG "Addr: ", DEC4 addr, "-", DEC4 addr + 15, " ",
|
||||
"Value: ", DEC3 result, CR
|
||||
NEXT
|
||||
PAUSE 100
|
||||
DEBUG CR, "All locations passed"
|
||||
END
|
||||
|
||||
|
||||
Error:
|
||||
DEBUG "Error at location: ", DEC4 addr + check, CR,
|
||||
"Found: ", DEC3 result(check), ", Expected: ", DEC3 value
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>IF...THEN...ELSE Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>IF...THEN...ELSE Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" /><span class="code_in_text"> {PBASIC 2.5}</span>
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/IF_THEN_ELSE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">IF…THEN…ELSE</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' IF-THEN-ELSE.BS2
|
||||
' The program below generates a series of 16-bit random numbers and tests
|
||||
' each to determine whether they're evenly divisible by 3. If a number is
|
||||
' evenly divisible by 3, then it is printed, otherwise, the program generates
|
||||
' another random number. The program counts how many numbers it prints, and
|
||||
' quits when this number reaches 10.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5} ' version 2.5 required
|
||||
|
||||
sample VAR Word ' Random number to be tested
|
||||
hits VAR Nib ' Number of hits
|
||||
misses VAR Word ' Number of misses
|
||||
|
||||
|
||||
Setup:
|
||||
sample = 11500
|
||||
|
||||
Main:
|
||||
DO
|
||||
RANDOM sample ' Put a random number into sample
|
||||
IF ((sample // 3) = 0) THEN ' divisible by 3?
|
||||
DEBUG DEC5 sample, ' - yes, print value and message
|
||||
" is divisible by 3", CR
|
||||
hits = hits + 1 ' count hits (divisble by 3)
|
||||
ELSE
|
||||
misses = misses + 1 ' count misses
|
||||
ENDIF
|
||||
LOOP UNTIL (hits = 10) ' quit after 10 hits
|
||||
|
||||
DEBUG CR,
|
||||
"All done.", CR, CR, ' display results
|
||||
"Hits: ", DEC hits, CR,
|
||||
"Misses: ", DEC misses, CR,
|
||||
"Samples: ", DEC (hits + misses)
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,121 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>IF...THEN Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>IF...THEN Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/IF_THEN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">IF…THEN</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p><pre class="BScode" xml:space="preserve">' IF-THEN.BS1
|
||||
' The program below generates a series of 16-bit random numbers and tests
|
||||
' each to determine whether they're evenly divisible by 3. If a number is
|
||||
' evenly divisible by 3, then it is printed, otherwise, the program generates
|
||||
' another random number. The program counts how many numbers it prints, and
|
||||
' quits when this number reaches 10.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL sample = W0 ' Random number to be tested
|
||||
SYMBOL samps = B2 ' Number of samples taken
|
||||
SYMBOL temp = B3 ' Temporary workspace
|
||||
|
||||
|
||||
Setup:
|
||||
sample = 11500
|
||||
|
||||
Mult3:
|
||||
RANDOM sample ' Put a random number into sample
|
||||
temp = sample // 3
|
||||
IF temp <> 0 THEN Mult3 ' Not multiple of 3? -- try again
|
||||
DEBUG #sample, "divides by 3", CR ' show sample divisible by 3
|
||||
samps = samps + 1 ' Count multiples of 3
|
||||
IF samps = 10 THEN Done ' Quit with 10 samples
|
||||
GOTO Mult3 ' keep checking
|
||||
|
||||
Done:
|
||||
DEBUG CR, "All done."
|
||||
END
|
||||
</pre>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' IF-THEN.BS2
|
||||
' The program below generates a series of 16-bit random numbers and tests
|
||||
' each to determine whether they're evenly divisible by 3. If a number is
|
||||
' evenly divisible by 3, then it is printed, otherwise, the program generates
|
||||
' another random number. The program counts how many numbers it prints, and
|
||||
' quits when this number reaches 10.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.0}
|
||||
|
||||
sample VAR Word ' Random number to be tested
|
||||
samps VAR Nib ' Number of samples taken
|
||||
temp VAR Nib ' Temporary workspace
|
||||
|
||||
|
||||
Setup:
|
||||
sample = 11500
|
||||
|
||||
Mult3:
|
||||
RANDOM sample ' Put a random number into sample
|
||||
temp = sample // 3
|
||||
IF (temp <> 0) THEN Mult3 ' Not multiple of 3? -- try again
|
||||
DEBUG DEC5 sample, " divides by 3", CR
|
||||
samps = samps + 1 ' Count multiples of 3
|
||||
IF samps = 10 THEN Done ' Quit with 10 samples
|
||||
GOTO Mult3 ' keep checking
|
||||
|
||||
Done:
|
||||
DEBUG CR, "All done."
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>INPUT / OUTPUT Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>INPUT / OUTPUT Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/INPUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">INPUT</a>, <a href="../Commands/OUTPUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">OUTPUT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p><pre class="BScode" xml:space="preserve">' INPUT_OUTPUT.BS1
|
||||
' This program demonstrates how the input/output direction of a pin is
|
||||
' determined by the corresponding bit of DIRS. It also shows that the
|
||||
' state of the pin itself (as reflected by the corresponding bit of PINS)
|
||||
' is determined by the outside world when the pin is an input, and by the
|
||||
' corresponding bit of PINS when it's an output. To set up the demo,
|
||||
' connect a 10k resistor from +5V to P7 on the BASIC Stamp. The resistor
|
||||
' to +5V puts a high (1) on the pin when it's an input. The BASIC Stamp
|
||||
' can override this state by writing a low (0) to bit 7 of OUTS and
|
||||
' changing the pin to output.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
|
||||
Main:
|
||||
INPUT 7 ' Make P7 an input
|
||||
DEBUG "State of P7: ", #PIN7, CR
|
||||
|
||||
PIN7 = 0 ' Write 0 to output latch
|
||||
DEBUG "After 0 written to OUT7: "
|
||||
DEBUG #PIN7, CR
|
||||
|
||||
OUTPUT 7 ' Make P7 an output
|
||||
DEBUG "After P7 changed to output: "
|
||||
DEBUG #PIN7
|
||||
END
|
||||
</pre>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' INPUT_OUTPUT.BS2
|
||||
' This program demonstrates how the input/output direction of a pin is
|
||||
' determined by the corresponding bit of DIRS. It also shows that the
|
||||
' state of the pin itself (as reflected by the corresponding bit of PINS)
|
||||
' is determined by the outside world when the pin is an input, and by the
|
||||
' corresponding bit of PINS when it's an output. To set up the demo,
|
||||
' connect a 10k resistor from +5V to P7 on the BASIC Stamp. The resistor
|
||||
' to +5V puts a high (1) on the pin when it's an input. The BASIC Stamp
|
||||
' can override this state by writing a low (0) to bit 7 of OUTS and
|
||||
' changing the pin to output.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
|
||||
Main:
|
||||
INPUT 7 ' Make P7 an input
|
||||
DEBUG "State of P7: ",
|
||||
BIN1 IN7, CR
|
||||
|
||||
OUT7 = 0 ' Write 0 to output latch
|
||||
DEBUG "After 0 written to OUT7: ",
|
||||
BIN1 IN7, CR
|
||||
|
||||
OUTPUT 7 ' Make P7 an output
|
||||
DEBUG "After P7 changed to output: ",
|
||||
BIN1 IN7
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>LCDCMD Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>LCDCMD Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/LCDCMD.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: This is written for the BS2p and will also run on the BS2pe and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2pe or BS2px.</p><pre class="BScode" xml:space="preserve">' LCDCMD.BSP
|
||||
' This program demonstrates initialization and printing on a 2 x 16
|
||||
' character LCD display. The set of "LCD constants", below, are provided
|
||||
' as pre-defined and useful LCD commands, though not all are actually
|
||||
' used in this program.
|
||||
|
||||
' {$STAMP BS2p}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
#IF ($STAMP < BS2P) #THEN
|
||||
#ERROR "Program requires BS2p, BS2pe, or BS2px."
|
||||
#ENDIF
|
||||
|
||||
Lcd PIN 0
|
||||
|
||||
LcdCls CON $01 ' clear the LCD
|
||||
LcdHome CON $02 ' move cursor home
|
||||
LcdCrsrL CON $10 ' move cursor left
|
||||
LcdCrsrR CON $14 ' move cursor right
|
||||
LcdDispL CON $18 ' shift chars left
|
||||
LcdDispR CON $1C ' shift chars right
|
||||
LcdDDRam CON $80 ' Display Data RAM
|
||||
LcdCGRam CON $40 ' Character Generator RAM
|
||||
LcdLine1 CON $80 ' DDRAM address of line 1
|
||||
LcdLine2 CON $C0 ' DDRAM address of line 2
|
||||
|
||||
|
||||
Init_LCD:
|
||||
PAUSE 1000 ' allow LCD to self-initialize first
|
||||
LCDCMD Lcd, %00110000 ' send wakeup sequence to LCD
|
||||
PAUSE 5 ' pause required by LCD specs
|
||||
LCDCMD Lcd, %00110000
|
||||
PAUSE 0 ' pause required by LCD specs
|
||||
LCDCMD Lcd, %00110000
|
||||
PAUSE 0 ' pause required by LCD specs
|
||||
LCDCMD Lcd, %00100000 ' set data bus to 4-bit mode
|
||||
LCDCMD Lcd, %00101000 ' set to 2-line mode with 5x8 font
|
||||
LCDCMD Lcd, %00001100 ' display on without cursor
|
||||
LCDCMD Lcd, %00000110 ' auto-increment cursor
|
||||
|
||||
Main:
|
||||
DO
|
||||
LCDOUT Lcd, LcdCls, ["Hello, World!"]
|
||||
LCDOUT Lcd, LcdLine2, ["How are you?"]
|
||||
PAUSE 3000
|
||||
LCDCMD Lcd, LcdCls
|
||||
PAUSE 500
|
||||
LOOP
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>LCDIN Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>LCDIN Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/LCDIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDIN</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: This is written for the BS2p and will also run on the BS2pe and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2pe or BS2px.</p><pre class="BScode" xml:space="preserve">' LCDIN.BSP
|
||||
' This program demonstrates initialization, printing and reading from
|
||||
' a 2 x 16 character LCD display.
|
||||
|
||||
' {$STAMP BS2p}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
#IF ($STAMP < BS2P) #THEN
|
||||
#ERROR "Program requires BS2p, BS2pe, or BS2px."
|
||||
#ENDIF
|
||||
|
||||
Lcd PIN 0
|
||||
|
||||
LcdCls CON $01 ' clear the LCD
|
||||
LcdHome CON $02 ' move cursor home
|
||||
LcdCrsrL CON $10 ' move cursor left
|
||||
LcdCrsrR CON $14 ' move cursor right
|
||||
LcdDispL CON $18 ' shift chars left
|
||||
LcdDispR CON $1C ' shift chars right
|
||||
LcdDDRam CON $80 ' Display Data RAM
|
||||
LcdCGRam CON $40 ' Character Generator RAM
|
||||
LcdLine1 CON $80 ' DDRAM address of line 1
|
||||
LcdLine2 CON $C0 ' DDRAM address of line 2
|
||||
|
||||
char VAR Byte(16)
|
||||
|
||||
|
||||
Init_LCD:
|
||||
PAUSE 1000 ' allow LCD to self-initialize first
|
||||
LCDCMD Lcd, %00110000 ' send wakeup sequence to LCD
|
||||
PAUSE 5 ' pause required by LCD specs
|
||||
LCDCMD Lcd, %00110000
|
||||
PAUSE 0 ' pause required by LCD specs
|
||||
LCDCMD Lcd, %00110000
|
||||
PAUSE 0 ' pause required by LCD specs
|
||||
LCDCMD Lcd, %00100000 ' set data bus to 4-bit mode
|
||||
LCDCMD Lcd, %00101000 ' set to 2-line mode with 5x8 font
|
||||
LCDCMD Lcd, %00001100 ' display on without cursor
|
||||
LCDCMD Lcd, %00000110 ' auto-increment cursor
|
||||
|
||||
Main:
|
||||
DO
|
||||
LCDOUT Lcd, LcdCls, ["Hello!"]
|
||||
GOSUB Read_LCD_Screen
|
||||
PAUSE 3000
|
||||
LCDOUT Lcd, LcdCls, ["I'm a 2x16 LCD!"]
|
||||
GOSUB Read_LCD_Screen
|
||||
PAUSE 3000
|
||||
LOOP
|
||||
END
|
||||
|
||||
Read_LCD_Screen:
|
||||
DEBUG "LCD now says: "
|
||||
LCDIN Lcd, LcdLine1, [STR char\16]
|
||||
DEBUG STR char\16, CR
|
||||
RETURN
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>LCDOUT Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>LCDOUT Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/LCDOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDOUT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: This is written for the BS2p and will also run on the BS2pe and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2pe or BS2px.</p><pre class="BScode" xml:space="preserve">' LCDOUT.BSP
|
||||
' This program demonstrates initialization and printing on a 2x16
|
||||
' character LCD display.
|
||||
|
||||
' {$STAMP BS2p}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
#IF ($STAMP < BS2P) #THEN
|
||||
#ERROR "Program requires BS2p, BS2pe, or BS2px."
|
||||
#ENDIF
|
||||
|
||||
Lcd PIN 0
|
||||
|
||||
LcdCls CON $01 ' clear the LCD
|
||||
LcdHome CON $02 ' move cursor home
|
||||
LcdCrsrL CON $10 ' move cursor left
|
||||
LcdCrsrR CON $14 ' move cursor right
|
||||
LcdDispL CON $18 ' shift chars left
|
||||
LcdDispR CON $1C ' shift chars right
|
||||
LcdDDRam CON $80 ' Display Data RAM
|
||||
LcdCGRam CON $40 ' Character Generator RAM
|
||||
LcdLine1 CON $80 ' DDRAM address of line 1
|
||||
LcdLine2 CON $C0 ' DDRAM address of line 2
|
||||
|
||||
|
||||
Init_LCD:
|
||||
PAUSE 1000 ' allow LCD to self-initialize first
|
||||
LCDCMD Lcd, %00110000 ' send wakeup sequence to LCD
|
||||
PAUSE 5 ' pause required by LCD specs
|
||||
LCDCMD Lcd, %00110000
|
||||
PAUSE 0 ' pause required by LCD specs
|
||||
LCDCMD Lcd, %00110000
|
||||
PAUSE 0 ' pause required by LCD specs
|
||||
LCDCMD Lcd, %00100000 ' set data bus to 4-bit mode
|
||||
LCDCMD Lcd, %00101000 ' set to 2-line mode with 5x8 font
|
||||
LCDCMD Lcd, %00001100 ' display on without cursor
|
||||
LCDCMD Lcd, %00000110 ' auto-increment cursor
|
||||
|
||||
LCDOUT Lcd, LcdCGRam, ' load custom chracter map
|
||||
[$00, $0A, $0A, $00, $11, $0E, $06, $00]
|
||||
|
||||
Main:
|
||||
DO
|
||||
LCDOUT Lcd, LcdCls, ["Hello my friend."]
|
||||
PAUSE 750
|
||||
LCDOUT Lcd, LcdLine2, ["How are you?"]
|
||||
PAUSE 1500
|
||||
LCDCMD Lcd, LcdCls
|
||||
LCDOUT Lcd, LcdLine1 + 1, ["I'm doing just"]
|
||||
LCDOUT Lcd, LcdLine2 + 4, ["fine! ", 0]
|
||||
PAUSE 2000
|
||||
LOOP
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>LOOKDOWN Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>LOOKDOWN Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/LOOKDOWN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LOOKDOWN</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p><pre class="BScode" xml:space="preserve">' LOOKDOWN.BS1
|
||||
' This program uses LOOKDOWN followed by LOOKUP to map the numbers:
|
||||
' 0, 10, 50, 64, 71 and 98 to 35, 40, 58, 62, 79, and 83, respectively.
|
||||
' All other numbers are mapped to 255.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL num = W0 ' holds current number
|
||||
SYMBOL result = W1 ' holds mapped result
|
||||
|
||||
|
||||
Main:
|
||||
FOR num = 0 TO 100
|
||||
result = 255 ' default value for no match
|
||||
LOOKDOWN num, (0, 10, 50, 64, 71, 98), result
|
||||
LOOKUP result, (35, 40, 58, 62, 79, 83), result
|
||||
DEBUG "Num = ", #num, "Result = ", #result, CR
|
||||
PAUSE 100
|
||||
NEXT
|
||||
END
|
||||
|
||||
</pre>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' LOOKDOWN.BS2
|
||||
' This program uses LOOKDOWN to determine the number of decimal digits in
|
||||
' a number. Since LOOKDOWN uses a zero-indexed table, the output will be
|
||||
' the number of digits minus one, so this gets corrected in the following
|
||||
' line. Note that zero is considered a valid number and has one digit.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
aNum VAR Word ' random number
|
||||
stpSz VAR Word ' FOR-NEXT step size
|
||||
numDig VAR Nib ' digits in aNum
|
||||
|
||||
|
||||
Setup:
|
||||
stpSz = 2
|
||||
|
||||
Main:
|
||||
FOR aNum = 0 TO 15000 STEP stpSz
|
||||
LOOKDOWN aNum, <[0, 10, 100, 1000, 10000, 65535], numDig
|
||||
' right-justify output
|
||||
DEBUG "aNum = ", REP " "\(5-numDig), DEC aNum, TAB,
|
||||
"Digits = ", DEC numDig, CR
|
||||
PAUSE 250
|
||||
LOOKDOWN aNum, <[0, 10, 100, 1000, 10000, 65535], stpSz
|
||||
LOOKUP stpSz, [2, 2, 5, 25, 250, 500, 1000], stpSz
|
||||
NEXT
|
||||
END
|
||||
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>LOOKUP Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>LOOKUP Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/LOOKUP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LOOKUP</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p><pre class="BScode" xml:space="preserve">' LOOKUP.BS1
|
||||
' This program uses LOOKUP to create a Debug-window animation of a spinning
|
||||
' propeller. The animation consists of the four ASCII characters | / - \
|
||||
' which, when printed rapidly in order at a fixed location, appear to spin.
|
||||
' A little imagination helps a lot here....
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBAsic 1.0}
|
||||
|
||||
SYMBOL idx = B2
|
||||
SYMBOL frame = B3
|
||||
|
||||
|
||||
Spinner:
|
||||
LOOKUP idx, ("|/-\"), frame ' lookup current frame character
|
||||
DEBUG CLS, "Spinner: ", #@frame ' display
|
||||
idx = idx + 1 // 4 ' update frame index (0..3)
|
||||
GOTO Spinner ' loop forever
|
||||
END</pre>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' LOOKUP.BS2
|
||||
' This program uses LOOKUP to create a Debug-window animation of a spinning
|
||||
' propeller. The animation consists of the four ASCII characters | / - \
|
||||
' which, when printed rapidly in order at a fixed location, appear to spin.
|
||||
' A little imagination helps a lot here....
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
idx VAR Nib
|
||||
frame VAR Byte
|
||||
|
||||
|
||||
Spinner:
|
||||
DO
|
||||
LOOKUP idx, ["|/-\"], frame ' lookup current frame character
|
||||
DEBUG HOME, "Spinner: ", frame ' display
|
||||
PAUSE 150 ' pause between frames
|
||||
idx = idx + 1 // 4 ' update frame index (0..3)
|
||||
LOOP ' loop forever
|
||||
END</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>NAP Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>NAP Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/NAP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">NAP</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p class="PlainText">Connect an LED and 470 Ω resistor as shown below for the demo program.</p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/led_sink.gif" />
|
||||
</p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' NAP.BS2
|
||||
' The program below lights an LED by placing a low on pin 0. This completes
|
||||
' the circuit from +5V, through the LED and resistor, to ground. During the
|
||||
' NAP interval, the LED stays lit, but blinks off for a fraction of a second.
|
||||
' This blink is caused by the NAP wakeup mechanism. During wakeup, all pins
|
||||
' briefly slip into input mode, effectively disconnecting them from loads.
|
||||
|
||||
' {$STAMP BS2}
|
||||
|
||||
|
||||
Setup:
|
||||
LOW 0 ' turn LED on
|
||||
|
||||
Snooze:
|
||||
NAP 4 ' nap for 288 ms
|
||||
GOTO Snooze
|
||||
END
|
||||
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>ON...GOSUB Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>ON...GOSUB Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" /><span class="code_in_text"> {PBASIC 2.5}</span>
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/NAP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">NAP</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' ON-GOSUB.BS2
|
||||
' This program demonstrates a simple task manager that can be used in
|
||||
' a variety of applications. It is particularly useful in robotics and
|
||||
' industrial applications. The advantage of this design is that task
|
||||
' code modules may be called from other places in the program, including
|
||||
' other tasks, and the overal program flow is maintained.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
task VAR Nib
|
||||
|
||||
|
||||
Main:
|
||||
DO
|
||||
ON task GOSUB Task_0, Task_1, Task_2 ' run current task
|
||||
task = task + 1 // 3 ' update task pointer
|
||||
PAUSE 1000
|
||||
LOOP
|
||||
END
|
||||
|
||||
Task_0:
|
||||
DEBUG "Running Task 0", CR
|
||||
RETURN
|
||||
|
||||
Task_1:
|
||||
DEBUG "Running Task 1", CR
|
||||
RETURN
|
||||
|
||||
Task_2:
|
||||
DEBUG "Running Task 2", CR
|
||||
RETURN
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>ON...GOTO Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>ON...GOTO Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" /><span class="code_in_text"> {PBASIC 2.5}</span>
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/ON_GOTO.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">ON...GOTO</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' ON-GOTO.BS2
|
||||
' This program shows how the value of idx controls the destination of the
|
||||
' ON...GOTO instruction.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
idx VAR Byte
|
||||
|
||||
|
||||
Main:
|
||||
DEBUG "idx: ", DEC idx, " "
|
||||
ON idx GOTO Case_0, Case_1, Case_2 ' if idx = 0..2 goto label
|
||||
DEBUG "ON..GOTO target error.", CR ' message if idx is out of range
|
||||
|
||||
Update:
|
||||
idx = idx + 1 // 4 ' force idx to be 0..3
|
||||
PAUSE 1000
|
||||
GOTO Main
|
||||
|
||||
Case_0:
|
||||
DEBUG "Running Case_0 routine", CR
|
||||
GOTO Update
|
||||
|
||||
Case_1:
|
||||
DEBUG "Running Case_1 routine", CR
|
||||
GOTO Update
|
||||
|
||||
Case_2:
|
||||
DEBUG "Running Case_2 routine", CR
|
||||
GOTO Update
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>OWIN / OWOUT Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>OWIN / OWOUT Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/OWIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">OWIN</a>, <a href="../Commands/OWOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">OWOUT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p class="PlainText">This program uses a Dallas Semiconductor DS1820 Digital Thermometer device connected as follows. Note that the 4.7 kΩ pull-up resistor is required for proper operation.</p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/ds1820_sch.gif" />
|
||||
</p>
|
||||
<p>NOTE: This is written for the BS2p and will also run on the BS2pe and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2pe or BS2px.</p><pre class="BScode" xml:space="preserve">' OWIN_OWOUT.BSP
|
||||
' This program demonstrates interfacing to a Dallas Semiconductor DS1822
|
||||
' 1-Wire Digital Thermometer chip using the BS2p's 1-Wire commands. Connect
|
||||
' the BS2p/BS2pe/BS2px to the DS1822 as shown in the diagram in the OWIN or
|
||||
' OWOUT command description. This program uses a simplified approach that
|
||||
' ignores the fractional portion of the temperature.
|
||||
|
||||
' {$STAMP BS2p}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
DQ PIN 0 ' 1-Wire buss pin
|
||||
|
||||
RdROM CON $33 ' read serial number
|
||||
MatchROM CON $55 ' match SN -- for multiple devices
|
||||
SkipROM CON $CC ' ignore SN -- use for one device
|
||||
CvrtTmp CON $44 ' start temperature conversion
|
||||
RdSP CON $BE ' read DS1822 scratchpad
|
||||
|
||||
tempIn VAR Word ' raw temperature
|
||||
sign VAR tempIn.BIT11 ' 1 = negative temperature
|
||||
tLo VAR tempIn.BYTE0
|
||||
tHi VAR tempIn.BYTE1
|
||||
tSign VAR Bit ' saved sign bit
|
||||
tempC VAR Word ' final Celsius temp
|
||||
tempF VAR Word ' final Fahrenheit temp
|
||||
|
||||
|
||||
Main:
|
||||
DO
|
||||
GOSUB Get_Temperature ' read temperature from DS1822
|
||||
DEBUG HOME, ' display
|
||||
"DS1822", CR,
|
||||
"------", CR,
|
||||
SDEC tempC, " C ", CR,
|
||||
SDEC tempF, " F "
|
||||
PAUSE 1000
|
||||
LOOP
|
||||
END
|
||||
|
||||
Get_Temperature:
|
||||
OWOUT DQ, 1, [SkipROM, CvrtTmp] ' send convert temperatrue command
|
||||
DO ' wait on conversion
|
||||
PAUSE 25 ' small loop pad
|
||||
OWIN DQ, 4, [tempIn] ' check status (bit transfer)
|
||||
LOOP UNTIL (tempIn) ' 1 when complete
|
||||
OWOUT DQ, 1, [SkipROM, RdSP] ' read DS1822 scratchpad
|
||||
OWIN DQ, 2, [tLo, tHi] ' get raw temp data
|
||||
tSign = sign ' save sign bit
|
||||
tempC = tempIn >> 4 ' round to whole degrees
|
||||
tempC.BYTE1 = $FF * tSign ' correct 2's compliment bits
|
||||
tempF = (ABS tempC) * 9 / 5 ' start F conversion
|
||||
IF (tSign) THEN ' finish F conversion
|
||||
tempF = 32 - tempF ' C was negative
|
||||
ELSE
|
||||
tempF = tempF + 32 ' C was positive
|
||||
ENDIF
|
||||
RETURN
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>PAUSE Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>PAUSE Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/PAUSE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">PAUSE</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: This is written for the BS2 and will run on any BASIC Stamp module. Modify the $STAMP directive (as required) before downloading to the BS1, BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' PAUSE.BS2
|
||||
' This program demonstrates the PAUSE command's time delays. Once a second,
|
||||
' the program will put the message, "Paused..." on the screen.
|
||||
|
||||
' {$STAMP BS2}
|
||||
|
||||
Main:
|
||||
DEBUG "Paused...", CR
|
||||
PAUSE 1000
|
||||
GOTO Main</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>POLLIN / POLLOUT / POLLMODE Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>POLLIN / POLLOUT / POLLMODE Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax:<a href="../Commands/POLLIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLIN</a>, <a href="../Commands/POLLOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLOUT</a>, <a href="../Commands/POLLMODE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLMODE</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/pollin_sch.gif" />
|
||||
</p>
|
||||
<p>NOTE: This is written for the BS2p and will also run on the BS2pe and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2pe or BS2px.</p><pre class="BScode" xml:space="preserve">' POLL.BSP
|
||||
' This program demonstrates POLLIN, POLLOUT, and the use of the POLLMODE
|
||||
' instruction. Connect active-low inputs to pins 0, 1, 2, and 3. Then
|
||||
' connect an LED to pin 7. The program will print "." to the Debug
|
||||
' window until one of the alarm buttons are pressed. This will cause
|
||||
' the termination of the main loop. At this point the program will
|
||||
' save the latched bits, clear them (and the polling process), then
|
||||
' report the input(s) that triggered the alarm.
|
||||
|
||||
' {$STAMP BS2p}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
|
||||
FDoor PIN 0
|
||||
BDoor PIN 1
|
||||
Patio PIN 2
|
||||
Rst PIN 3
|
||||
AlarmLed PIN 7
|
||||
|
||||
alarms VAR Byte ' alarm bits
|
||||
idx VAR Nib ' loop control
|
||||
|
||||
|
||||
Setup:
|
||||
POLLIN FDoor, 0 ' define alarm inputs
|
||||
POLLIN BDoor, 0
|
||||
POLLIN Patio, 0
|
||||
POLLOUT AlarmLed, 1 ' alarm indicator
|
||||
POLLMODE 10 ' activate latched polling
|
||||
DEBUG CLS,
|
||||
"Alarms Activated", CR
|
||||
|
||||
Main:
|
||||
DO
|
||||
DEBUG "." ' foreground activity
|
||||
PAUSE 50
|
||||
LOOP UNTIL (AlarmLed = 1) ' loop until LED is on
|
||||
GET 128, alarms ' get alarm bits
|
||||
POLLMODE 0 ' deactivate polling
|
||||
|
||||
Report:
|
||||
DEBUG CLS, ' alarms report
|
||||
"Front Door : ", CR,
|
||||
"Back Door : ", CR,
|
||||
"Patio : ", CR
|
||||
|
||||
FOR idx = 0 TO 2 ' scan alarm bits
|
||||
DEBUG CRSRXY, 13, idx ' move cursor
|
||||
IF (alarms.LOWBIT(idx)) THEN ' report each bit status
|
||||
DEBUG "Alarm", CR
|
||||
ELSE
|
||||
DEBUG "-", CR
|
||||
ENDIF
|
||||
NEXT
|
||||
DEBUG CR, "Press RESET to clear..."
|
||||
DO : LOOP UNTIL (Rst = 0) ' wait until Rst pressed
|
||||
GOTO Setup
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>POLLRUN Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>POLLRUN Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/POLLRUN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLRUN</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p>NOTE: This is written for the BS2p and will also run on the BS2pe and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2pe or BS2px.</p><pre class="BScode" xml:space="preserve">' POLLRUN0.BSP
|
||||
' This program demonstrates the POLLRUN command. It is intended to be
|
||||
' downloaded to program slot 0, and the program called PROGRUN1.BSP
|
||||
' should be downloaded to program slot 1. I/O pin 0 is set to watch for
|
||||
' a low signal. Once the Main routine starts running, the program
|
||||
' continuously prints it's program slot number to the screen. If I/O
|
||||
' pin 0 goes low, the program in program slot 1 (which should be
|
||||
' POLLRUN1.BSP) is run.
|
||||
|
||||
' {$STAMP BS2p, POLLRUN1.BSP}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
pgmSlot VAR Byte
|
||||
|
||||
Setup:
|
||||
POLLIN 0, 0 ' polled-input, look for 0
|
||||
POLLRUN 1 ' run slot 1 on polled activation
|
||||
POLLMODE 3 ' enable polling
|
||||
|
||||
Main:
|
||||
GET 127, pgmSlot
|
||||
DEBUG "Running Program #", DEC pgmSlot.LOWNIB, CR
|
||||
GOTO Main
|
||||
END
|
||||
</pre><pre class="BScode" xml:space="preserve">' POLLRUN1.BSP
|
||||
' This program demonstrates the POLLRUN command. It is intended to be
|
||||
' downloaded to program slot 1, and the program called PROGRUN0.BSP
|
||||
' should be downloaded to program slot 0. This program is run when
|
||||
' program 0 detects a low on I/O pin 0 via the polled commands.
|
||||
|
||||
' {$STAMP BS2p}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
pgmSlot VAR Byte
|
||||
|
||||
Main:
|
||||
GET 127, pgmSlot
|
||||
DEBUG "Running Program #", DEC pgmSlot.LOWNIB, CR
|
||||
GOTO Main
|
||||
END
|
||||
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>POLLWAIT Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>POLLWAIT Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/POLLWAIT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLWAIT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: This is written for the BS2p and will also run on the BS2pe and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2pe or BS2px.</p><pre class="BScode" xml:space="preserve">' POLLWAIT.BSP
|
||||
' This program demonstrates the POLLWAIT command. I/O pin 0 is set to
|
||||
' watch for a low signal. Once the Main routine starts running, the
|
||||
' POLLWAIT command causes the program to halt until the polled event
|
||||
' happens (I/O pin is low) then it prints a message on the PC screen.
|
||||
' It will do nothing until I/O pin is low.
|
||||
|
||||
' {$STAMP BS2p}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
|
||||
Setup:
|
||||
POLLIN 0, 0 ' polled-input, look for 0
|
||||
POLLMODE 2 ' enable polling
|
||||
|
||||
Main:
|
||||
POLLWAIT 8 ' Wait for polled event
|
||||
DEBUG "I/O pin 0 is LOW!", CR ' Print message
|
||||
GOTO Main
|
||||
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>POT Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>POT Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" /><span class="code_in_text"> {PBASIC 1.0}</span>
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/POT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/pot_demo_sch.gif" />
|
||||
</p><pre class="BScode" xml:space="preserve">' POT.BS1
|
||||
' This program demonstrates the use of the POT command. Connect one side
|
||||
' of a 10K potiometer to P0. To the other side of the potentiomenter
|
||||
' connect a 0.1 uF capacitor, and then connect the second side of the
|
||||
' capacitor to Vss (ground). Before running demo program, use the
|
||||
' Run | POT Scaling dialog to determine the best Scale factor.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL PotPin = 0 ' 10K pot connected to P0
|
||||
SYMBOL Scale = 110 ' scale value for test circuit
|
||||
|
||||
SYMBOL level = B2 ' storage of pot "level"
|
||||
|
||||
Main:
|
||||
POT PotPin, Scale, level ' read pot level
|
||||
DEBUG CLS, "Level = ", #level ' display
|
||||
PAUSE 50 ' short delay
|
||||
GOTO Main ' repeat forever
|
||||
END
|
||||
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>PULSIN Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>PULSIN Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/PULSIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">PULSIN</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/pulsin_sch.gif" />
|
||||
</p><pre class="BScode" xml:space="preserve">' PULSIN.BS1
|
||||
' This program uses PULSIN to measure a pulse generated by discharging a
|
||||
' 0.1 uF capacitor through a 1K resistor. Pressing the switch generates
|
||||
' the pulse, which should ideally be approximately 120 us (12 PULSIN units
|
||||
' of 10 us) long. Variations in component values may produce results that
|
||||
' are up to 10 units off from this value. For more information on calculating
|
||||
' resistor-capacitor timing, see the RCTIME command.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL Pulse = 7 ' pulse input pin
|
||||
|
||||
SYMBOL time = W1 ' pulse width (10 uS units)
|
||||
|
||||
|
||||
Main:
|
||||
PULSIN Pulse, 1, time ' measure positive pulse
|
||||
IF time = 0 THEN Main ' if 0, try again
|
||||
DEBUG CLS, time ' else display result
|
||||
GOTO Main
|
||||
END
|
||||
|
||||
</pre>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' PULSIN.BS2
|
||||
' This program uses PULSIN to measure a pulse generated by discharging a
|
||||
' 0.1 uF capacitor through a 1K resistor. Pressing the switch generates
|
||||
' the pulse, which should ideally be approximately 120 us (60 PULSIN units
|
||||
' of 2 us) long (for BS2 and BS2e). Variations in component values may
|
||||
' produce results that are up to 10 units off from this value. For more
|
||||
' information on calculating resistor-capacitor timing, see the RCTIME
|
||||
' command.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
Pulse PIN 7 ' pulse input pin
|
||||
|
||||
#SELECT $STAMP
|
||||
#CASE BS2, BS2E, BS2PE
|
||||
Scale CON $200 ' 2.0 us per unit
|
||||
#CASE BS2SX
|
||||
Scale CON $0CD ' 0.8 us per unit
|
||||
#CASE BS2P
|
||||
Scale CON $0C0 ' 0.75 us per unit
|
||||
#CASE BS2PX
|
||||
Scale CON $0CF ' 0.81 us per unit
|
||||
#ENDSELECT
|
||||
|
||||
time VAR Word
|
||||
|
||||
|
||||
Main:
|
||||
PULSIN Pulse, 1, time ' measure positive pulse
|
||||
IF (time > 0) THEN ' if not 0
|
||||
DEBUG HOME,
|
||||
DEC time, " units ", CLREOL ' display raw input
|
||||
time = time */ Scale ' adjust for Stamp
|
||||
DEBUG CR,
|
||||
DEC time, " us " ' display microseconds
|
||||
ELSE
|
||||
DEBUG CLS, "Out of Range" ' else error message
|
||||
ENDIF
|
||||
PAUSE 200
|
||||
GOTO Main
|
||||
END</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>PULSOUT Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>PULSOUT Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/PULSOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">PULSOUT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/led_sink.gif" />
|
||||
</p>
|
||||
<p class="PlainText">Connect an LED and 470 Ω resistor as shown below for the demo program.</p><pre class="BScode" xml:space="preserve">' PULSOUT.BS1
|
||||
' This program blinks an LED on for 25 ms at 1-second intervals. Connect an
|
||||
' LED (active-low) to I/O pin 0.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
|
||||
Setup:
|
||||
HIGH 0 ' make P0 high (LED off)
|
||||
|
||||
Main:
|
||||
PULSOUT 0, 2500 ' flash LED for 25 ms
|
||||
PAUSE 1000 ' one second delay
|
||||
GOTO Main
|
||||
END
|
||||
</pre>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' PULSOUT.BS2
|
||||
' This program blinks an LED on for 25 ms at 1-second intervals. Connect an
|
||||
' LED (active-low) to I/O pin 0.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
#SELECT $STAMP
|
||||
#CASE BS2, BS2E, BS2PE
|
||||
Scale CON 500 ' to ms for 2 us per unit
|
||||
#CASE BS2SX, BS2P, BS2PX
|
||||
Scale CON 1250 ' to ms for 0.8 us per unit
|
||||
#ENDSELECT
|
||||
|
||||
Flash CON 25 * Scale ' 25 milliseconds
|
||||
|
||||
|
||||
Setup:
|
||||
HIGH 0 ' make P0 high (LED off)
|
||||
|
||||
Main:
|
||||
PULSOUT 0, Flash ' flash LED
|
||||
PAUSE 1000 ' one second delay
|
||||
GOTO Main
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>PWM Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>PWM Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Sytnax: <a href="../Commands/PWM.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">PWM</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/pwm_sch.gif" />
|
||||
</p><pre class="BScode" xml:space="preserve">' PWM.BS1
|
||||
' Connect a voltmeter (such as a digital multimeter set to its voltage
|
||||
' range) to the output of the circuit shown in the figure for the PWM
|
||||
' command (in the manual). Run the program and observe the readings on
|
||||
' the meter. They should come very close to 1.96V, then decrease slightly
|
||||
' as the capacitor discharges. Try varying the interval between PWM bursts
|
||||
' (by changing the PAUSE value) and the number of PWM cycles to see their
|
||||
' effect.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
|
||||
Main:
|
||||
PWM 0, 100, 10 ' PWM at 100/255 duty (~50 ms)
|
||||
PAUSE 1000 ' wait one second
|
||||
GOTO Main
|
||||
END
|
||||
|
||||
</pre>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' PWM.BS2
|
||||
' Connect a voltmeter (such as a digital multimeter set to its voltage
|
||||
' range) to the output of the circuit shown in the figure for the PWM
|
||||
' command (in the manual). Run the program and observe the readings on
|
||||
' the meter. They should come very close to 1.96V, then decrease slightly
|
||||
' as the capacitor discharges. Try varying the interval between PWM bursts
|
||||
' (by changing the PAUSE value) and the number of PWM cycles to see their
|
||||
' effect.
|
||||
|
||||
' {$STAMP BS2p}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
#SELECT $STAMP
|
||||
#CASE BS2, BS2E
|
||||
CycAdj CON $100 ' x 1.0, cycle ajustment (for ms)
|
||||
#CASE BS2SX
|
||||
CycAdj CON $280 ' x 2.5
|
||||
#CASE BS2P
|
||||
CycAdj CON $187 ' x 1.53
|
||||
#CASE BS2PE
|
||||
CycAdj CON $09E ' x 0.62
|
||||
#CASE BS2PX
|
||||
CycAdj CON $280 ' x 2.5
|
||||
#ENDSELECT
|
||||
|
||||
Cycles CON 50
|
||||
|
||||
|
||||
Main:
|
||||
PWM 0, 100, (Cycles */ CycAdj) ' PWM at 100/255 duty (~50 ms)
|
||||
PAUSE 1000 ' wait one second
|
||||
GOTO Main
|
||||
END
|
||||
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>RANDOM Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>RANDOM Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/RANDOM.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">RANDOM</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/random_sch.gif" />
|
||||
</p><pre class="BScode" xml:space="preserve">' RANDOM.BS1
|
||||
' Connect a button to I/O pin 7 as shown in the figure in the RANDOM
|
||||
' command description and run this program. This program uses RANDOM to
|
||||
' simulate a coin toss. After 100 trials, it reports the total number of
|
||||
' heads and tails thrown.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL Btn = 7 ' button input
|
||||
|
||||
SYMBOL flip = W0 ' a random number
|
||||
SYMBOL coin = BIT0 ' a bit from random number
|
||||
SYMBOL trials = B2 ' number of flips
|
||||
SYMBOL heads = B3 ' throws that come up heads
|
||||
SYMBOL tails = B4 ' throws that come up tails
|
||||
SYMBOL btnWrk = B5 ' workspace for BUTTON
|
||||
|
||||
|
||||
Start:
|
||||
DEBUG CLS, "Press the button to toss coin.", CR
|
||||
|
||||
Main:
|
||||
FOR trials = 1 TO 100 ' flip coin 100 times
|
||||
|
||||
Hold:
|
||||
RANDOM flip ' randomize while waiting
|
||||
BUTTON Btn, 0, 250, 100, btnWrk, 0, Hold ' wait for button press
|
||||
BRANCH coin, (Head, Tail) ' 0 = heads, 1 = tails
|
||||
|
||||
Head:
|
||||
DEBUG CR, "Heads!"
|
||||
heads = heads + 1 ' increment heads counter
|
||||
GOTO Next_Toss
|
||||
|
||||
Tail:
|
||||
DEBUG CR, "Tails..."
|
||||
tails = tails + 1 ' increment heads counter
|
||||
|
||||
Next_Toss:
|
||||
NEXT
|
||||
|
||||
DEBUG CR, CR, "Heads: ", #heads, CR, "Tails: ", #tails
|
||||
END
|
||||
|
||||
</pre>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' RANDOM.BS2
|
||||
' Connect a button to I/O pin 7 as shown in the figure in the RANDOM
|
||||
' command description and run this program. This program uses RANDOM to
|
||||
' simulate a coin toss. After 100 trials, it reports the total number of
|
||||
' heads and tails thrown.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
Btn PIN 7 ' button input
|
||||
|
||||
flip VAR Word ' a random number
|
||||
coin VAR flip.BIT0 ' Bit0 of the random number
|
||||
trials VAR Byte ' number of flips
|
||||
heads VAR Byte ' throws that come up heads
|
||||
tails VAR Byte ' throws that come up tails
|
||||
btnWrk VAR Byte ' workspace for BUTTON
|
||||
|
||||
|
||||
Start:
|
||||
DEBUG CLS, "Press button to start"
|
||||
|
||||
Main:
|
||||
FOR trials = 1 TO 100 ' flip coin 100 times
|
||||
|
||||
Hold:
|
||||
RANDOM flip ' randomize while waiting
|
||||
BUTTON Btin, 0, 250, 100, btnWrk, 0, Hold ' wait for button press
|
||||
IF (coin = 0) THEN ' 0 = heads, 1 = tails
|
||||
DEBUG CR, "Heads!"
|
||||
heads = heads + 1 ' increment heads counter
|
||||
ELSE
|
||||
DEBUG CR, "Tails..."
|
||||
tails = tails + 1 ' increment tails counter
|
||||
ENDIF
|
||||
NEXT
|
||||
|
||||
Done:
|
||||
DEBUG CR, CR, "Heads: ", DEC heads, " Tails: ", DEC tails
|
||||
END</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,132 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>RCTIME Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>RCTIME Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/RCTIME.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">RCTIME</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p>
|
||||
<p class="PlainText" style="text-align: center;"> </p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/rctime_demo_sch.gif" />
|
||||
</p><pre class="BScode" xml:space="preserve">' RCTIME1.BS2
|
||||
' This program shows the standard use of the RCTIME instruction measuring
|
||||
' an RC charge/discharge time. Use the circuit in the RCTIME description
|
||||
' (in the manual) with R = 10K pot and C = 0.1 uF. Connect the circuit to
|
||||
' pin 7 and run the program. Adjust the pot and watch the value shown on
|
||||
' the Debug screen change.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
RC PIN 7
|
||||
|
||||
result VAR Word
|
||||
|
||||
|
||||
Main:
|
||||
DO
|
||||
HIGH RC ' charge the cap
|
||||
PAUSE 1 ' for 1 ms
|
||||
RCTIME RC, 1, result ' measure RC discharge time
|
||||
DEBUG HOME, DEC result ' display value
|
||||
PAUSE 50
|
||||
LOOP
|
||||
END
|
||||
</pre>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p>
|
||||
<p class="PlainText" style="text-align: center;"> </p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/rctime2_sch.gif" />
|
||||
</p><pre class="BScode" xml:space="preserve">' RCTIME2.BS2
|
||||
' This program illustrates the use of RCTIME as a fast stopwatch. The
|
||||
' program energizes a relay coil, then measures how long it takes for the
|
||||
' relay contacts to close. The circuit for this program can be found in
|
||||
' the manual. Note that RCTIME doesn't start timing instantly -- as with
|
||||
' all PBASIC instructions, it must be fetched from program EEPROM before
|
||||
' it can execute.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
Coil PIN 6
|
||||
RC PIN 7
|
||||
|
||||
#SELECT $STAMP
|
||||
#CASE BS2, BS2E, BS2PE
|
||||
Adjust CON $200 ' x 2 us per unit
|
||||
#CASE BS2SX
|
||||
Adjust CON $0CC ' x 0.8 us per unit
|
||||
#CASE BS2P
|
||||
Adjust CON $0C0 ' x 0.75 us per unit
|
||||
#CASE BS2PX
|
||||
Adjust CON $0C0 ' x 0.75 us per unit
|
||||
#ENDSELECT
|
||||
|
||||
result VAR Word
|
||||
|
||||
|
||||
Main:
|
||||
DO
|
||||
LOW Coil ' energize relay coil
|
||||
RCTIME RC, 1, result ' measure time to contact closure
|
||||
result = result */ Adjust ' adjust for device
|
||||
DEBUG "Time to close: ",
|
||||
DEC Result, CR
|
||||
HIGH Coil ' release relay
|
||||
PAUSE 1000 ' wait one second
|
||||
LOOP
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,121 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>READ Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>READ Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/READ.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">READ</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p><pre class="BScode" xml:space="preserve">' READ.BS1
|
||||
' This program reads a string of data stored in EEPROM. The EEPROM data is
|
||||
' downloaded to the BS1 at compile-time and remains there (even with the
|
||||
' power off) until overwritten. Put ASCII characters into EEPROM, followed
|
||||
' by 0, which will serve as the end-of-message marker. For programs with
|
||||
' multiple strings, use the Memory Map window to find the starting character
|
||||
' address.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL strAddr = B2
|
||||
SYMBOL char = B3
|
||||
|
||||
Msg1:
|
||||
EEPROM ("BS1", 13, "EEPROM Storage!", 0)
|
||||
|
||||
|
||||
Main:
|
||||
strAddr = 0 ' set to start of message
|
||||
GOSUB String_Out
|
||||
END
|
||||
|
||||
String_Out:
|
||||
READ strAddr, char ' read byte from EEPROM
|
||||
strAddr = strAddr + 1 ' point to next character
|
||||
IF char = 0 THEN StrOut_Exit ' if 0, exit routine
|
||||
DEBUG #@char ' otherwise print char
|
||||
GOTO String_Out ' get next character
|
||||
|
||||
StrOut_Exit:
|
||||
RETURN</pre>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' READ.BS2
|
||||
' This program reads a string of data stored in EEPROM. The EEPROM data is
|
||||
' downloaded to the BS2 at compile-time and remains there (even with the
|
||||
' power off) until overwritten. Put ASCII characters into EEPROM, followed
|
||||
' by 0, which will serve as the end-of-message marker.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
strAddr VAR Word
|
||||
char VAR Byte
|
||||
|
||||
Msg1 DATA "BS2", CR, "EEPROM Storage!", 0
|
||||
|
||||
|
||||
Main:
|
||||
strAddr = Msg ' set to start of message
|
||||
GOSUB String_Out
|
||||
END
|
||||
|
||||
String_Out:
|
||||
DO
|
||||
READ strAddr, char ' read byte from EEPROM
|
||||
strAddr = strAddr + 1 ' point to next character
|
||||
IF (char = 0) THEN EXIT ' if 0, exit routine
|
||||
DEBUG char ' otherwise print char
|
||||
LOOP
|
||||
RETURN
|
||||
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>RETURN Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>RETURN Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/RETURN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">RETURN</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: This is written for the BS2 and will run on any BASIC Stamp module. Modify the $STAMP directive (as required) before downloading to the BS1, BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' RETURN.BS2
|
||||
' This program demonstrates a potential bug caused by allowing a program to
|
||||
' "fall into" a subroutine. The program was intented to indicate that it
|
||||
' is "Starting...", then "Executing Subroutine,", then "Returned..." from
|
||||
' the subroutine and stop. Since we left out the END command (indicated in
|
||||
' the comments), the program then falls into the subroutine, displays
|
||||
' "Executing..." again and then RETURNs to the start of the program and
|
||||
' runs continuously in an endless loop.
|
||||
|
||||
' {$STAMP BS2}
|
||||
|
||||
|
||||
Reset:
|
||||
DEBUG "Starting Program", CR ' show start-up
|
||||
|
||||
Main:
|
||||
PAUSE 1000
|
||||
GOSUB Demo_Sub ' call the subroutine
|
||||
PAUSE 1000
|
||||
DEBUG "Returned from Subroutine", CR ' show that we're back
|
||||
PAUSE 1000
|
||||
' <-- Forgot to put END here
|
||||
|
||||
Demo_Sub:
|
||||
DEBUG " Executing Subroutine", CR ' show subroutine activity
|
||||
RETURN</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>REVERSE Examples</title>
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>REVERSE Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" /><span class="code_in_text"> {PBASIC 2.5}</span>
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Example</p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p class="PlainText">Connect an LED and two resistors as shown below for the demo program.</p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/reverse_sch.gif" />
|
||||
</p><pre class="BScode" xml:space="preserve">' REVERSE.BS1
|
||||
' Connect the circuit shown in the REVERSE command description to I/O pin
|
||||
' 0 and run this program. The LED will alternate between two states, dim
|
||||
' and bright. The BASIC Stamp is using the REVERSE command to toggling I/O
|
||||
' pin 0 between input and output states. When pin 0 is an input, current
|
||||
' flows through R1, through the LED, through R2 to ground. Pin 0 is
|
||||
' effectively disconnected and doesn't play a part in the circuit. The total
|
||||
' resistance encountered by current flowing through the LED is R1 + R2 = 1220
|
||||
' ohms. When pin 0 is reversed to an output, current flows through R1, through
|
||||
' the LED, and into pin 0 to ground (because of the 0 written to PIN0). The
|
||||
' total resistance encountered by current flowing through the LED is R1,
|
||||
' 220 ohms. With only 20% of the resistance, the LED glows brighter.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
|
||||
Setup:
|
||||
PIN0 = 0 ' Put a low in the pin 0
|
||||
' output driver
|
||||
Main:
|
||||
PAUSE 250 ' 1/4th second pause
|
||||
REVERSE 0 ' reverse pin 0 I/O direction
|
||||
GOTO Main ' do forever
|
||||
|
||||
</pre>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve"> REVERSE.BS2
|
||||
' Connect the circuit shown in the REVERSE command description to I/O pin
|
||||
' 0 and run this program. The LED will alternate between two states, dim
|
||||
' and bright. The BASIC Stamp is using the REVERSE command to toggling I/O
|
||||
' pin 0 between input and output states. When pin 0 is an input, current
|
||||
' flows through R1, through the LED, through R2 to ground. Pin 0 is
|
||||
' effectively disconnected and doesn't play a part in the circuit. The total
|
||||
' resistance encountered by current flowing through the LED is R1 + R2 = 1220
|
||||
' ohms. When pin 0 is reversed to an output, current flows through R1, through
|
||||
' the LED, and into pin 0 to ground (because of the 0 written to OUT0). The
|
||||
' total resistance encountered by current flowing through the LED is R1,
|
||||
' 220 ohms. With only 20% of the resistance, the LED glows brighter.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
|
||||
Setup:
|
||||
OUT0 = 0 ' Put a low in the pin 0
|
||||
' output driver
|
||||
Main:
|
||||
PAUSE 250 ' 1/4th second pause
|
||||
REVERSE 0 ' reverse pin 0 I/O direction
|
||||
GOTO Main ' do forever
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>RUN Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>RUN Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/RUN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">RUN</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: This is written for the BS2sx and will also run on the BS2e, BS2p, BS2pe, and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' RUN1.BSX
|
||||
' This example demonstrates the use of the RUN command. First, the SPRAM
|
||||
' location that holds the current slot is read using the GET command to
|
||||
' display the currently running program number. Then a set of values (based
|
||||
' on the program number) are displayed on the screen. Afterwards, program
|
||||
' number 1 is run. This program is a BS2sx project consisting of RUN1.BSX
|
||||
' and RUN2.BSX, but will run on all multi-slot BASIC Stamp models.
|
||||
|
||||
' {$STAMP BS2sx, RUN2.BSX}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
#SELECT $STAMP ' set SPRAM of slot number
|
||||
#CASE BS2
|
||||
#ERROR "Multi-slot BASIC Stamp required."
|
||||
#CASE BS2E, BS2SX
|
||||
Slot CON 63
|
||||
#CASE BS2P, BS2PE, BS2PX
|
||||
Slot CON 127
|
||||
#ENDSELECT
|
||||
|
||||
slotNum VAR Nib ' current slot
|
||||
idx VAR Nib ' loop counter
|
||||
value VAR Byte ' value from EEPROM
|
||||
|
||||
EEtable DATA 100, 40, 80, 32, 90
|
||||
DATA 200, 65, 23, 77, 91
|
||||
|
||||
|
||||
Setup:
|
||||
GET Slot, slotNum ' read current slot
|
||||
DEBUG "Program #", DEC slotNum, CR ' display
|
||||
|
||||
Main:
|
||||
FOR idx = 0 TO 4 ' read/display table values
|
||||
READ (slotNum * 5) + idx, value
|
||||
DEBUG DEC3 value, " "
|
||||
NEXT
|
||||
DEBUG CR
|
||||
PAUSE 1000
|
||||
|
||||
RUN 1 ' run Slot 1 pgm
|
||||
|
||||
</pre>
|
||||
<p class="PlainText" xml:space="preserve"> </p><pre class="BScode" xml:space="preserve">' RUN2.BSX
|
||||
' This example demonstrates the use of the RUN command. First, the SPRAM
|
||||
' location that holds the current slot is read using the GET command to
|
||||
' display the currently running program number. Then a set of values (based
|
||||
' on the program number) are displayed on the screen. Afterwards, program
|
||||
' number 0 is run. This program is a BS2sx project consisting of RUN1.BSX
|
||||
' and RUN2.BSX, but will run on all multi-slot BASIC Stamp models.
|
||||
|
||||
' {$STAMP BS2sx}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
#SELECT $STAMP ' set SPRAM of slot number
|
||||
#CASE BS2
|
||||
#ERROR "Multi-slot BASIC Stamp required."
|
||||
#CASE BS2E, BS2SX
|
||||
Slot CON 63
|
||||
#CASE BS2P, BS2PE, BS2PX
|
||||
Slot CON 127
|
||||
#ENDSELECT
|
||||
|
||||
slotNum VAR Nib ' current slot
|
||||
idx VAR Nib ' loop counter
|
||||
value VAR Byte ' value from EEPROM
|
||||
|
||||
EEtable DATA 100, 40, 80, 32, 90
|
||||
DATA 200, 65, 23, 77, 91
|
||||
|
||||
|
||||
Setup:
|
||||
GET Slot, slotNum ' read current slot
|
||||
DEBUG "Program #", DEC slotNum, CR ' display
|
||||
|
||||
Main:
|
||||
FOR idx = 0 TO 4 ' read/display table values
|
||||
READ (slotNum * 5) + idx, value
|
||||
DEBUG DEC3 value, " "
|
||||
NEXT
|
||||
DEBUG CR
|
||||
PAUSE 1000
|
||||
|
||||
RUN 0 ' back to Slot 0 pgm
|
||||
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>SELECT...CASE Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>SELECT...CASE Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" /><span class="code_in_text"> {PBASIC 2.5}</span>
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax:<a href="../Commands/SELECT_CASE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SELECT...CASE</a> <![CDATA[ ]]></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' SELECT-CASE.BS2
|
||||
' This program generates a series of 16-bit random numbers and tests each
|
||||
' to determine odd or even, and where it falls in the possible range:
|
||||
' lower third, middle third, or upper third. The program is useful for
|
||||
' testing various seed values for RANDOM.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
test VAR Byte ' counter for tests
|
||||
sample VAR Word ' random number to be tested
|
||||
odd VAR Byte ' odd throws
|
||||
even VAR Byte ' even throws
|
||||
isLo VAR Byte ' sample in lower third
|
||||
isMid VAR Byte ' in middle thrid
|
||||
isHi VAR Byte ' in upper third
|
||||
|
||||
|
||||
Main:
|
||||
sample = 11000 ' initialize seed
|
||||
FOR test = 1 TO 100 ' "throw" 100 times
|
||||
RANDOM sample ' randomize
|
||||
|
||||
IF (sample.BIT0) THEN ' check odd/even bit
|
||||
odd = odd + 1 ' increment odd count
|
||||
ELSE
|
||||
even = even + 1 ' increment even count
|
||||
ENDIF
|
||||
|
||||
SELECT sample
|
||||
CASE <= 21845 ' test lower third
|
||||
isLo = isLo + 1
|
||||
|
||||
CASE 21846 TO 43691 ' test middle third
|
||||
isMid = isMid + 1
|
||||
|
||||
CASE ELSE ' otherwise upper third
|
||||
isHi = isHi + 1
|
||||
ENDSELECT
|
||||
NEXT
|
||||
|
||||
Show_Results:
|
||||
DEBUG CLS,
|
||||
"Odd Throws.... ", DEC odd, "%", CR,
|
||||
"Even Throws... ", DEC even, "%", CR,
|
||||
"Low........... ", DEC isLo, "%", CR,
|
||||
"Mid........... ", DEC isMid, "%", CR,
|
||||
"High.......... ", DEC isHi, "%", CR
|
||||
END</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,184 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>SERIN Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>SERIN Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/SERIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SERIN</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p><pre class="BScode" xml:space="preserve">' SERIN.BS1
|
||||
' This program waits for the characters "A", "B", "C", and "D" to arrive
|
||||
' at the serial input (inverted, 2400 baud, N81), followed by a number,
|
||||
' then a carriage-return or some other non-number character. The number is
|
||||
' then displayed in the Debug window.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL SIn = 0
|
||||
SYMBOL Baud = N2400
|
||||
|
||||
SYMBOL result = W1
|
||||
|
||||
|
||||
Main:
|
||||
SERIN SIn, Baud, ("ABCD"), #result
|
||||
DEBUG #result, CR
|
||||
GOTO Main
|
||||
END</pre>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p>
|
||||
<p class="PlainText">
|
||||
<img src="../../graphics/flow_ctrl_sch.gif" />
|
||||
</p><pre class="BScode" xml:space="preserve">' SERIN_SEROUT1.BS2
|
||||
' Using two BS2-IC's, connect the circuit shown in the SERIN command
|
||||
' description and run this program on the BASIC Stamp designated as the
|
||||
' Sender. This program demonstrates the use of Flow Control (FPin).
|
||||
' Without flow control, the sender would transmit the whole word "Hello!"
|
||||
' in about 1.5 ms. The receiver would catch the first byte at most; by the
|
||||
' time it got back from the first 1-second PAUSE, the rest of the data
|
||||
' would be long gone. With flow control, communication is flawless since
|
||||
' the sender waits for the receiver to catch up.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
SO PIN 1 ' serial output
|
||||
FC PIN 0 ' flow control pin
|
||||
|
||||
#SELECT $STAMP
|
||||
#CASE BS2, BS2E, BS2PE
|
||||
T1200 CON 813
|
||||
T2400 CON 396
|
||||
T9600 CON 84
|
||||
T19K2 CON 32
|
||||
T38K4 CON 6
|
||||
#CASE BS2SX, BS2P
|
||||
T1200 CON 2063
|
||||
T2400 CON 1021
|
||||
T9600 CON 240
|
||||
T19K2 CON 110
|
||||
T38K4 CON 45
|
||||
#CASE BS2PX
|
||||
T1200 CON 3313
|
||||
T2400 CON 1646
|
||||
T9600 CON 396
|
||||
T19K2 CON 188
|
||||
T38K4 CON 84
|
||||
#ENDSELECT
|
||||
|
||||
Inverted CON $4000
|
||||
Open CON $8000
|
||||
Baud CON T38K4 + Inverted
|
||||
|
||||
|
||||
Main:
|
||||
DO
|
||||
SEROUT SO\FC, Baud, ["Hello!", CR] ' send the greeting
|
||||
PAUSE 2500 ' wait 2.5 seconds
|
||||
LOOP ' repeat forever
|
||||
END
|
||||
</pre>
|
||||
<p class="PlainText"> </p><pre class="BScode" xml:space="preserve">' SERIN_SEROUT2.BS2
|
||||
' Using two BS2-IC's, connect the circuit shown in the SERIN command
|
||||
' description and run this program on the BASIC Stamp designated as the
|
||||
' Receiver. This program demonstrates the use of Flow Control (FPin).
|
||||
' Without flow control, the sender would transmit the whole word "Hello!"
|
||||
' in about 1.5 ms. The receiver would catch the first byte at most; by the
|
||||
' time it got back from the first 1-second PAUSE, the rest of the data
|
||||
' would be long gone. With flow control, communication is flawless since
|
||||
' the sender waits for the receiver to catch up.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
SI PIN 1 ' serial input
|
||||
FC PIN 0 ' flow control pin
|
||||
|
||||
#SELECT $STAMP
|
||||
#CASE BS2, BS2E, BS2PE
|
||||
T1200 CON 813
|
||||
T2400 CON 396
|
||||
T9600 CON 84
|
||||
T19K2 CON 32
|
||||
T38K4 CON 6
|
||||
#CASE BS2SX, BS2P
|
||||
T1200 CON 2063
|
||||
T2400 CON 1021
|
||||
T9600 CON 240
|
||||
T19K2 CON 110
|
||||
T38K4 CON 45
|
||||
#CASE BS2PX
|
||||
T1200 CON 3313
|
||||
T2400 CON 1646
|
||||
T9600 CON 396
|
||||
T19K2 CON 188
|
||||
T38K4 CON 84
|
||||
#ENDSELECT
|
||||
|
||||
Inverted CON $4000
|
||||
Open CON $8000
|
||||
Baud CON T38K4 + Inverted
|
||||
|
||||
letter VAR Byte
|
||||
|
||||
|
||||
Main:
|
||||
DO
|
||||
SERIN SI\FC, Baud, [letter] ' recieve one byte
|
||||
DEBUG letter ' display on screen
|
||||
PAUSE 1000 ' wait one second
|
||||
LOOP ' repeat forever
|
||||
END
|
||||
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,190 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>SEROUT Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>SEROUT Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/SEROUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SEROUT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p><pre class="BScode" xml:space="preserve">' SEROUT.BS1
|
||||
' This program transmits the string "ABCD" followed by a number and a
|
||||
' carriage-return at 2400 baud, inverted, N81 format.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL SOut = 1
|
||||
SYMBOL Baud = N2400
|
||||
|
||||
SYMBOL value = W1
|
||||
|
||||
|
||||
Setup:
|
||||
value = 1
|
||||
|
||||
Main:
|
||||
SEROUT SOut, Baud, ("ABCD", #value)
|
||||
value = value + 1
|
||||
PAUSE 250
|
||||
GOTO Main
|
||||
END
|
||||
|
||||
</pre>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/flow_ctrl_sch.gif" />
|
||||
</p><pre class="BScode" xml:space="preserve">' SERIN_SEROUT1.BS2
|
||||
' Using two BS2-IC's, connect the circuit shown in the SERIN command
|
||||
' description and run this program on the BASIC Stamp designated as the
|
||||
' Sender. This program demonstrates the use of Flow Control (FPin).
|
||||
' Without flow control, the sender would transmit the whole word "Hello!"
|
||||
' in about 1.5 ms. The receiver would catch the first byte at most; by the
|
||||
' time it got back from the first 1-second PAUSE, the rest of the data
|
||||
' would be long gone. With flow control, communication is flawless since
|
||||
' the sender waits for the receiver to catch up.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
SO PIN 1 ' serial output
|
||||
FC PIN 0 ' flow control pin
|
||||
|
||||
#SELECT $STAMP
|
||||
#CASE BS2, BS2E, BS2PE
|
||||
T1200 CON 813
|
||||
T2400 CON 396
|
||||
T9600 CON 84
|
||||
T19K2 CON 32
|
||||
T38K4 CON 6
|
||||
#CASE BS2SX, BS2P
|
||||
T1200 CON 2063
|
||||
T2400 CON 1021
|
||||
T9600 CON 240
|
||||
T19K2 CON 110
|
||||
T38K4 CON 45
|
||||
#CASE BS2PX
|
||||
T1200 CON 3313
|
||||
T2400 CON 1646
|
||||
T9600 CON 396
|
||||
T19K2 CON 188
|
||||
T38K4 CON 84
|
||||
#ENDSELECT
|
||||
|
||||
Inverted CON $4000
|
||||
Open CON $8000
|
||||
Baud CON T38K4 + Inverted
|
||||
|
||||
|
||||
Main:
|
||||
DO
|
||||
SEROUT SO\FC, Baud, ["Hello!", CR] ' send the greeting
|
||||
PAUSE 2500 ' wait 2.5 seconds
|
||||
LOOP ' repeat forever
|
||||
END
|
||||
|
||||
' SERIN_SEROUT2.BS2
|
||||
|
||||
</pre><pre class="BScode" xml:space="preserve">' SERIN_SEROUT2.BS2
|
||||
' Using two BS2-IC's, connect the circuit shown in the SERIN command
|
||||
' description and run this program on the BASIC Stamp designated as the
|
||||
' Receiver. This program demonstrates the use of Flow Control (FPin).
|
||||
' Without flow control, the sender would transmit the whole word "Hello!"
|
||||
' in about 1.5 ms. The receiver would catch the first byte at most; by the
|
||||
' time it got back from the first 1-second PAUSE, the rest of the data
|
||||
' would be long gone. With flow control, communication is flawless since
|
||||
' the sender waits for the receiver to catch up.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
SI PIN 0 ' serial input
|
||||
FC PIN 1 ' flow control pin
|
||||
|
||||
#SELECT $STAMP
|
||||
#CASE BS2, BS2E, BS2PE
|
||||
T1200 CON 813
|
||||
T2400 CON 396
|
||||
T9600 CON 84
|
||||
T19K2 CON 32
|
||||
T38K4 CON 6
|
||||
#CASE BS2SX, BS2P
|
||||
T1200 CON 2063
|
||||
T2400 CON 1021
|
||||
T9600 CON 240
|
||||
T19K2 CON 110
|
||||
T38K4 CON 45
|
||||
#CASE BS2PX
|
||||
T1200 CON 3313
|
||||
T2400 CON 1646
|
||||
T9600 CON 396
|
||||
T19K2 CON 188
|
||||
T38K4 CON 84
|
||||
#ENDSELECT
|
||||
|
||||
Inverted CON $4000
|
||||
Open CON $8000
|
||||
Baud CON T38K4 + Inverted
|
||||
|
||||
letter VAR Byte
|
||||
|
||||
|
||||
Main:
|
||||
DO
|
||||
SERIN SI/FC, Baud, [letter] ' recieve one byte
|
||||
DEBUG letter ' display on screen
|
||||
PAUSE 1000 ' wait one second
|
||||
LOOP ' repeat forever
|
||||
END
|
||||
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>SHIFTIN Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>SHIFTIN Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/SHIFTIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SHIFTIN</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/ADC0831_sch.gif" />
|
||||
</p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' SHIFTIN.BS2
|
||||
' This program uses the SHIFTIN instruction to interface with the ADC0831
|
||||
' 8-bit analog-to-digital converter from National Semiconductor.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
CS PIN 0 ' chip select
|
||||
AData PIN 1 ' data pin
|
||||
Clk PIN 2 ' clock pin
|
||||
|
||||
adcRes VAR Byte ' ADC result
|
||||
|
||||
|
||||
Setup:
|
||||
HIGH CS ' deselect ADC
|
||||
|
||||
' In the loop below, just three lines of code are required to read the
|
||||
' ADC0831. The SHIFTIN command does most of the work. The mode argument in
|
||||
' the SHIFTIN command specifies MSB or LSB-first and whether to sample data
|
||||
' before or after the clock. In this case, we chose MSB-first, post-clock.
|
||||
' The ADC0831 precedes its data output with a dummy bit, which we take care
|
||||
' of by specifying 9 bits of data instead of 8.
|
||||
|
||||
Main:
|
||||
DO
|
||||
LOW CS ' activate the ADC0831
|
||||
SHIFTIN AData, Clk, MSBPOST, [adcRes\9] ' shift in the data
|
||||
HIGH CS ' deactivate ADC0831
|
||||
DEBUG ? adcRes ' show conversion result
|
||||
PAUSE 1000 ' wait one second
|
||||
LOOP ' repeat
|
||||
END
|
||||
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>SHIFTOUT Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>SHIFTOUT Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/SHIFTOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SHIFTOUT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/74HC595_sch.gif" />
|
||||
</p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' SHIFTOUT.BS2
|
||||
' This program uses the SHIFTOUT command to interface to the 74HC595 shift
|
||||
' register as an 8-bit output port. The '595 requires a minimum of three
|
||||
' inputs: data, clock, and latch. See the figure in the SHIFTOUT command
|
||||
' description in the manual for wiring information. SHIFTOUT automatically
|
||||
' handles the data and clock, pulsing the clock to shift data bits into the
|
||||
' '595. An extra step (pulsing the latch input) is required to move the
|
||||
' shifted bits in parallel onto the '595's output pins. Note: this code does
|
||||
' not control the output-enable or reset lines of the '595. This means that
|
||||
' before the BASIC Stamp first sends, the '595's output latches are turned
|
||||
' on and may contain random data. In critical applications, you should hold
|
||||
' output-enable high (disabled) until the BASIC Stamp can take control.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
Dpin PIN 0 ' data pin to 74HC595
|
||||
Clk PIN 1 ' shift clock to 74HC595
|
||||
Latch PIN 2 ' latch 74HC595 outputs
|
||||
|
||||
counter VAR Byte
|
||||
|
||||
|
||||
Setup:
|
||||
LOW Latch ' initialize latch output
|
||||
|
||||
' This loop moves the 8-bit value 'counter' onto the output lines of the
|
||||
' '595, pauses, then increments counter and repeats. The data is shifted
|
||||
' MSB first so that the MSB appears on pin QH and the lsb on QA. Changing
|
||||
' MSBFIRST to LSBFIRST causes the data to appear backwards on the outputs.
|
||||
|
||||
Main:
|
||||
DO
|
||||
SHIFTOUT Dpin, Clk, MSBFIRST, [counter] ' send the bits
|
||||
PULSOUT Latch, 1 ' transfer to outputs
|
||||
PAUSE 100 ' Wait 0.1 seconds
|
||||
counter = counter + 1 ' increment counter
|
||||
LOOP
|
||||
END</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>SLEEP Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>SLEEP Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/SLEEP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SLEEP</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p class="PlainText">Connect an LED and 470 Ω resistor as shown below for the demo program.</p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/led_sink.gif" />
|
||||
</p>
|
||||
<p>NOTE: This is written for the BS2 and will run on any BASIC Stamp module. Modify the $STAMP directive (as required) before downloading to the BS1, BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' SLEEP.BS2
|
||||
' This program lights an LED and then goes to sleep. Connect an LED to pin
|
||||
' 0 as shown in the description of SLEEP in the manual and run the program.
|
||||
' The LED will turn on, then the BASIC Stamp will go to sleep. During sleep,
|
||||
' the LED will remain on, but will blink at intervals of approximately 2.3
|
||||
' seconds due to the watchdog timeout and reset.
|
||||
|
||||
' {$STAMP BS2}
|
||||
|
||||
|
||||
Setup:
|
||||
LOW 0 ' turn LED on
|
||||
|
||||
Snooze:
|
||||
SLEEP 10 ' sleep for approximately 10 seconds
|
||||
GOTO Snooze
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>SOUND Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>SOUND Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" /><span class="code_in_text"> {PBASIC 1.0}</span>
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/SOUND.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SOUND</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p><pre class="BScode" xml:space="preserve">' SOUND.BS1
|
||||
' This program generates a constant tone 25 followed by an ascending tones.
|
||||
' Both the tones have the same duration.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL tone = B2
|
||||
|
||||
|
||||
Main:
|
||||
FOR tone = 0 TO 255
|
||||
SOUND 0, (25, 10, tone, 10)
|
||||
NEXT
|
||||
END</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>STOP Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>STOP Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/STOP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">STOP</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/led_sink.gif" />
|
||||
</p>
|
||||
<p>NOTE: This is written for the BS2p and will also run on the BS2pe and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2pe or BS2px.</p><pre class="BScode" xml:space="preserve">' STOP.BS2
|
||||
' This program is similar to SLEEP.BS2 except that the LED will not blink
|
||||
' since the BASIC Stamp does not go into low power mode. Use the circuit
|
||||
' shown in the description of the SLEEP command for this example.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
|
||||
Main:
|
||||
LOW 0 ' turn LED on
|
||||
STOP </pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,239 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>STORE Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>STORE Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/STORE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">STORE</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: This is written for the BS2p and will also run on the BS2pe and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2pe or BS2px.</p><pre class="BScode" xml:space="preserve">' STORE0.BSP
|
||||
' This program demonstrates the STORE command and how it affects the READ
|
||||
' and WRITE commands. This program "STORE0.BSP" is intended to be down-
|
||||
' loaded into program slot 0. It is meant to work with STORE1.BSP and
|
||||
' STORE2.BSP. Each program is very similar (they display the current
|
||||
' Program Slot and READ/WRITE Slot numbers and the values contained in the
|
||||
' first five EEPROM locations. Each program slot will have different data
|
||||
' due to different DATA commands in each of the programs downloaded.
|
||||
|
||||
' {$STAMP BS2p, STORE1.BSP, STORE2.BSP}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
#IF ($STAMP < BS2P) #THEN
|
||||
#ERROR "This program requires BS2p, BS2pe, or BS2px"
|
||||
#ENDIF
|
||||
|
||||
idx VAR Word ' index
|
||||
value VAR Byte
|
||||
|
||||
LocalData DATA @0, 1, 2, 3, 4, 5
|
||||
|
||||
|
||||
Main:
|
||||
GOSUB Show_Slot_Info ' show slot info/data
|
||||
PAUSE 2000
|
||||
STORE 1 ' point READ/WRITE to Slot 1
|
||||
GOSUB Show_Slot_Info
|
||||
PAUSE 2000
|
||||
RUN 1 ' run program in Slot 1
|
||||
END
|
||||
|
||||
Show_Slot_Info:
|
||||
GET 127, value
|
||||
DEBUG CR, "Pgm Slot: ", DEC value.NIB0,
|
||||
CR, "R/W Slot: ", DEC value.NIB1,
|
||||
CR, CR
|
||||
|
||||
FOR idx = 0 TO 4
|
||||
READ idx, value
|
||||
DEBUG "Location: ", DEC idx, TAB,
|
||||
"Value: ", DEC3 value, CR
|
||||
NEXT
|
||||
RETURN
|
||||
|
||||
</pre><pre class="BScode" xml:space="preserve">' STORE1.BSP
|
||||
|
||||
' {$STAMP BS2p}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
idx VAR Word ' index
|
||||
value VAR Byte
|
||||
|
||||
LocalData DATA @0, 6, 7, 8, 9, 10
|
||||
|
||||
|
||||
Main:
|
||||
GOSUB Show_Slot_Info ' show slot info/data
|
||||
PAUSE 2000
|
||||
STORE 0 ' point READ/WRITE to Slot 0
|
||||
GOSUB Show_Slot_Info
|
||||
PAUSE 2000
|
||||
RUN 2 ' run program in Slot 2
|
||||
END
|
||||
|
||||
Show_Slot_Info:
|
||||
GET 127, value
|
||||
DEBUG CR, "Pgm Slot: ", DEC value.NIB0,
|
||||
CR, "R/W Slot: ", DEC value.NIB1,
|
||||
CR, CR
|
||||
|
||||
FOR idx = 0 TO 4
|
||||
READ idx, value
|
||||
DEBUG "Location: ", DEC idx, TAB,
|
||||
"Value: ", DEC3 value, CR
|
||||
NEXT
|
||||
RETURN
|
||||
|
||||
</pre><pre class="BScode" xml:space="preserve">' STORE2.BSP
|
||||
|
||||
' {$STAMP BS2p}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
idx VAR Word ' index
|
||||
value VAR Byte
|
||||
|
||||
LocalData DATA @0, 11, 12, 13, 14, 15
|
||||
|
||||
|
||||
Main:
|
||||
GOSUB Show_Slot_Info ' show slot info/data
|
||||
PAUSE 2000
|
||||
STORE 0 ' point READ/WRITE to Slot 0
|
||||
GOSUB Show_Slot_Info
|
||||
END
|
||||
|
||||
Show_Slot_Info:
|
||||
GET 127, value
|
||||
DEBUG CR, "Pgm Slot: ", DEC value.NIB0,
|
||||
CR, "R/W Slot: ", DEC value.NIB1,
|
||||
CR, CR
|
||||
|
||||
FOR idx = 0 TO 4
|
||||
READ idx, value
|
||||
DEBUG "Location: ", DEC idx, TAB,
|
||||
"Value: ", DEC3 value, CR
|
||||
NEXT
|
||||
RETURN
|
||||
|
||||
</pre>
|
||||
<p class="PlainText"> </p>
|
||||
<p class="PlainText">The next program, STOREALL.BSP, is not related to the previous three programs. STOREALL.BSP demonstrates the use of the <span class="keyword_in_text">STORE</span> command to treat contiguous program slots as one block of memory (14 kBytes for the BS2p and BS2px, 30 kBytes for the BS2pe). This illustrates one of the most powerful uses of the <span class="keyword_in_text">STORE</span> command.</p>
|
||||
<p>NOTE: This is written for the BS2p and will also run on the BS2pe and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2pe or BS2px.</p><pre class="BScode" xml:space="preserve">' STOREALL.BSP
|
||||
' This program demonstrates the STORE command and how it can be used to
|
||||
' "flatten" the EEPROM space for applications requiring a lot of storage.
|
||||
' This program writes to EEPROM locations within program slots 1 through 7
|
||||
' on the BS2p and BS2px, and 1 through 15 on the BS2pe, thus, has access
|
||||
' to 14- or 30-kBytes of space.
|
||||
|
||||
' {$STAMP BS2p}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
#SELECT $STAMP
|
||||
#CASE BS2, BS2E, BS2SX
|
||||
#ERROR "This program requires BS2p, BS2pe, or BS2px"
|
||||
#CASE BS2P, BS2PX
|
||||
HiSlot CON 7
|
||||
#CASE BS2PE
|
||||
HiSlot CON 15
|
||||
#ENDSELECT
|
||||
|
||||
LoSlot CON 1 ' first slot for "flat" EE
|
||||
MemSize CON HiSlot - LoSlot + 1 * 2048
|
||||
|
||||
eeAddr VAR Word ' address pointer
|
||||
value VAR Word ' cell value
|
||||
slot VAR Byte ' current R/W slot
|
||||
|
||||
|
||||
Main:
|
||||
DEBUG "Flat Memory", CR,
|
||||
"---------------------", CR,
|
||||
"First Slot..... ", DEC LoSlot, CR,
|
||||
"Last Slot...... ", DEC HiSlot, CR,
|
||||
"Flat EE Size... ", DEC MemSize, CR, CR
|
||||
|
||||
PAUSE 2000
|
||||
DEBUG "Writing to flat Memory...", CR
|
||||
PAUSE 1000
|
||||
FOR eeAddr = 0 TO (MemSize - 1) STEP 128 ' step through "flat" EE
|
||||
value = eeAddr * 2 ' generate value
|
||||
GOSUB Write_Word ' write it
|
||||
GET 127, slot ' get R/W slot
|
||||
DEBUG "--> Location: ", DEC5 eeAddr, " ", ' show "flat" address
|
||||
"Value: ", DEC5 value, " ", ' show value
|
||||
"(", DEC slot.NIB1, ")", CR ' show slot
|
||||
NEXT
|
||||
DEBUG CR
|
||||
|
||||
DEBUG "Reading from flat Memory...", CR
|
||||
PAUSE 1000
|
||||
FOR eeAddr = 0 TO (MemSize - 1) STEP 128
|
||||
GOSUB Read_Word ' read value from EE
|
||||
GET 127, slot ' get W/R slot
|
||||
DEBUG "<-- Location: ", DEC5 eeAddr, " ",
|
||||
"Value: ", DEC5 value, " ",
|
||||
"(", DEC slot.NIB1, ") "
|
||||
IF (value <> (2 * eeAddr)) THEN ' verify location
|
||||
DEBUG "- Error"
|
||||
ENDIF
|
||||
DEBUG CR
|
||||
NEXT
|
||||
END
|
||||
|
||||
Write_Word:
|
||||
STORE (eeAddr >> 11) + LoSlot ' set slot
|
||||
WRITE eeAddr, Word value ' write value
|
||||
RETURN
|
||||
|
||||
Read_Word:
|
||||
STORE (eeAddr >> 11) + LoSlot ' set slot
|
||||
READ eeAddr, Word value ' read value
|
||||
RETURN
|
||||
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>TOGGLE Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>TOGGLE Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/TOGGLE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">TOGGLE</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p> </p>
|
||||
<p class="PlainText">Connect four LEDs and four 470 Ω resistors as show below for the demo program.</p>
|
||||
<p class="PlainText" style="text-align: center;">
|
||||
<img src="../../graphics/toggle_sch.gif" />
|
||||
</p><pre class="BScode" xml:space="preserve">' TOGGLE.BS1
|
||||
' Connect LEDs to pins 0 through 3 as shown in the TOGGLE command descrip-
|
||||
' tion in the manual and run this program. The TOGGLE command will treat
|
||||
' you to a light show. You may also run the demo without LEDs. The Debug
|
||||
' window will show you the states of pins 0 through 3.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL thePin = B0 ' pin 0 - 3
|
||||
|
||||
|
||||
Setup:
|
||||
DIRS = %1111 ' make LEDs output, low
|
||||
|
||||
Main:
|
||||
FOR thePin = 0 TO 3 ' loop through pins
|
||||
TOGGLE thePin ' toggle current pin
|
||||
DEBUG CLS, %PINS ' show on Debug
|
||||
PAUSE 100 ' short delay
|
||||
NEXT
|
||||
GOTO Main ' repeat forever
|
||||
END
|
||||
|
||||
</pre>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' TOGGLE.BS2
|
||||
' Connect LEDs to pins 0 through 3 as shown in the TOGGLE command descrip-
|
||||
' tion in the manual and run this program. The TOGGLE command will treat
|
||||
' you to a light show. You may also run the demo without LEDs. The Debug
|
||||
' window will show you the states of pins 0 through 3.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
thePin VAR Nib ' pin 0 - 3
|
||||
|
||||
|
||||
Setup:
|
||||
DIRA = %1111 ' make LEDs output, low
|
||||
|
||||
Main:
|
||||
DO
|
||||
FOR thePin = 0 TO 3 ' loop through pins
|
||||
TOGGLE thePin ' toggle current pin
|
||||
DEBUG HOME, BIN4 OUTA ' show on Debug
|
||||
PAUSE 250 ' short delay
|
||||
NEXT
|
||||
LOOP ' repeat forever
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>WRITE Examples</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>WRITE Examples</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/WRITE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">WRITE</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p><pre class="BScode" xml:space="preserve">' WRITE.BS1
|
||||
' This program writes a few bytes to EEPROM and then reads them back out
|
||||
' and displays them in the Debug window.
|
||||
|
||||
' {$STAMP BS1}
|
||||
' {$PBASIC 1.0}
|
||||
|
||||
SYMBOL addr = B2 ' address
|
||||
SYMBOL value = B3 ' value
|
||||
|
||||
|
||||
Main:
|
||||
WRITE 0, 100 ' write some data to locations 0 - 3
|
||||
WRITE 1, 200
|
||||
WRITE 2, 45
|
||||
WRITE 3, 28
|
||||
|
||||
Read_EE:
|
||||
FOR addr = 0 TO 3
|
||||
READ addr, value ' read value from address
|
||||
DEBUG #addr, ": ", #value, CR ' display address and value
|
||||
NEXT
|
||||
END
|
||||
|
||||
</pre>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' WRITE.BS2
|
||||
' This program writes some data to EEPROM and then reads them back out
|
||||
' and displays the data in the Debug window.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
idx VAR Byte ' loop control
|
||||
value VAR Word(3) ' value(s)
|
||||
|
||||
|
||||
Main:
|
||||
WRITE 0, 100 ' single byte
|
||||
WRITE 1, Word 1250 ' single word
|
||||
WRITE 3, 45, 90, Word 725 ' multi-value write
|
||||
|
||||
Read_EE:
|
||||
FOR idx = 0 TO 6 ' show raw bytes in EE
|
||||
READ idx, value
|
||||
DEBUG DEC1 idx, " : ", DEC value, CR
|
||||
NEXT
|
||||
DEBUG CR
|
||||
|
||||
' read values as stored
|
||||
|
||||
READ 0, value
|
||||
DEBUG DEC value, CR
|
||||
READ 1, Word value
|
||||
DEBUG DEC value, CR
|
||||
READ 3, value(0), value(1), Word value(2)
|
||||
FOR idx = 0 TO 2
|
||||
DEBUG DEC value(idx), CR
|
||||
NEXT
|
||||
END
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
||||
<head><title>XOUT Example</title>
|
||||
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
||||
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
||||
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>XOUT Example</h1>
|
||||
<div class="ImagePlusCaption">
|
||||
<div class="Col2">
|
||||
<p>
|
||||
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
||||
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
||||
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
||||
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
||||
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
||||
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
||||
</p>
|
||||
</div>
|
||||
<p style="text-align: right;">Syntax: <a href="../Commands/XOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">XOUT</a></p>
|
||||
<p> </p>
|
||||
</div>
|
||||
<p class="clear"> </p>
|
||||
<p class="PlainText"> </p>
|
||||
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' XOUT.BS2
|
||||
' This program--really two program fragments--demonstrates the syntax and
|
||||
' use of the XOUT command. XOUT works like pressing the buttons on an X-10
|
||||
' control box; first you press one of 16 keys to identify the unit you want
|
||||
' to control, then you press the key for the action you want that unit to
|
||||
' take (turn ON, OFF, Bright, or Dim). There are also two group-action keys,
|
||||
' Lights ON and All OFF. Lights ON turns all lamp modules on without
|
||||
' affecting appliance modules. All OFF turns off all modules, both lamp and
|
||||
' appliance types. Connect the BASIC Stamp to a power-line interface as
|
||||
' shown in the XOUT command description in the manual.
|
||||
|
||||
' {$STAMP BS2}
|
||||
' {$PBASIC 2.5}
|
||||
|
||||
Mpin PIN 1 ' modulation pin
|
||||
Zpin PIN 0 ' zero-cross input
|
||||
|
||||
HouseA CON 0 ' House code A = 0
|
||||
Unit1 CON 0 ' Unit code 1 = 0
|
||||
Unit2 CON 1 ' Unit code 2 = 1
|
||||
|
||||
' This first example turns a standard (appliance or non-dimmer lamp) module
|
||||
' ON, then OFF. Note that once the Unit code is sent, it need not be repeated
|
||||
' --subsequent instructions are understood to be addressed to that unit.
|
||||
|
||||
Main:
|
||||
XOUT Mpin, Zpin, [HouseA\Unit1\2] ' select Unit1 (appliance module)
|
||||
XOUT Mpin, Zpin, [HouseA\UNITON] ' turn it on
|
||||
|
||||
PAUSE 1000 ' wait one second
|
||||
|
||||
XOUT Mpin, Zpin, [HouseA\UNITOFF] ' then turn it off
|
||||
|
||||
' The next example talks to a lamp module using the dimmer feature. Dimmers
|
||||
' go from full ON to dimmed OFF in 19 steps. Because dimming is relative to
|
||||
' the current state of the lamp, the only guaranteed way to set a predefined
|
||||
' brightness level is to turn the dimmer fully OFF, then ON, then dim to the
|
||||
' desired level.
|
||||
|
||||
XOUT Mpin, Zpin, [HouseA\Unit2\2] ' select Unit2 (lamp module)
|
||||
|
||||
' This example shows the use of the optional Cycles argument. Here we DIM
|
||||
' for 10 cycles.
|
||||
|
||||
XOUT Mpin, Zpin, [HouseA\UNITOFF\2, HouseA\DIM\10]
|
||||
STOP
|
||||
</pre>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Col2">
|
||||
<div class="MasterFoot">
|
||||
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
||||
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
||||
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">/* <![CDATA[ */
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-285614-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
/* ]]> */</script>
|
||||
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user