User manual
8. Example SNAPpy Scripts
The fastest way to get familiar with the SNAPpy scripng 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 descripon 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
starng points.
NOTE – some 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 funcon
correctly without user modificaon.
General Purpose Scripts
Script Name What it does
BaeryMonitor.py Demonstrates interfacing to an external voltage reference in
order to determine baery power.
BuiltIn.py (synapse.BuiltIn.py) Portal uses this script to provide doc strings and parameter
assistance for all the built-in funcons. Several features in
Portal will not work if you edit, move, or remove this file.
buzzer.py Generates a short beep when the buon is pressed. Also
provides a “buzzer service” to other nodes. The example
script DarkDetector.py shows one example of using this
script. (This requires connecon of a piezo buzzer to your
node, hardware included in the EK2100 kit.)
CommandLine.py An example of implemenng 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 evaluaon
boards.
DarkDetector.py Monitors a photocell via an analog input, and displays a
“darkness level” value on the seven-segment display on
supported Synapse evaluaon 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 sophiscated example of implemenng a wireless
UART.
SNAP® Network Operang System 49