User manual

8. Example SNAPpy Scripts
The fastest way to get familiar with the SNAPpy scripng language is to see it in use. Portal comes with several
example scripts pre-installed in the snappyImages directory.
Here is a list of the scripts preinstalled with Portal 2.4, along with a short descripon of what each script does.
Take a look at these to get ideas for your own custom scripts. You can also copy these scripts, and use them as
starng points.
NOTEsome of these scripts are meant to be imported into other scripts. Also, some of these scripts are
found in a “synapse” subdirectory inside the “snappyImages” directory.
NOTE - Some example scripts predate newer SNAP Engines (such as the SM220) and may not funcon
correctly without user modificaon.
General Purpose Scripts
Script Name What it does
BaeryMonitor.py Demonstrates interfacing to an external voltage reference in
order to determine baery power.
BuiltIn.py (synapse.BuiltIn.py) Portal uses this script to provide doc strings and parameter
assistance for all the built-in funcons. Several features in
Portal will not work if you edit, move, or remove this file.
buzzer.py Generates a short beep when the buon is pressed. Also
provides a “buzzer service” to other nodes. The example
script DarkDetector.py shows one example of using this
script. (This requires connecon of a piezo buzzer to your
node, hardware included in the EK2100 kit.)
CommandLine.py An example of implemenng a command line on the UART
that is normally available on SNAP Engine pins GPIO9 through
GPIO12. Provides commands for LED, relay, and seven-
segment display control on supported Synapse evaluaon
boards.
DarkDetector.py Monitors a photocell via an analog input, and displays a
“darkness level” value on the seven-segment display on
supported Synapse evaluaon boards. Also requests a short
beep from a node running the buzzer.py script when a
threshold value is crossed.
DarkroomTimer.py Operates a dark room enlarger light under user control.
datamode.py An example of using two nodes to replace a serial cable.
dataModeNV.py A more sophiscated example of implemenng a wireless
UART.
SNAP® Network Operang System 49