Specifications
9. Example SNAPpy Scripts
The fastest way to get familiar with the SNAPpy scripting 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 description 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 starting 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.
General Purpose Scripts
Script Name What it does
BatteryMonitor.py Demonstrates interfacing to an external voltage reference
in order to determine battery power.
BuiltIn.py (synapse.BuiltIn.py) Portal uses this script to provide doc strings and
parameter assistance for all the built-in functions. You
must not edit, move, or remove this file.
buzzer.py Generates a short beep when the button is pressed. Also
provides a “buzzer service” to other nodes. The example
script DarkDetector.py shows one example of using this
script.
CommandLine.py An example of implementing 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
DarkDetector.py Monitors a photocell via an analog input, and displays a
“percent darkness” value on the seven-segment display.
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 sophisticated example of implementing a
wireless UART
evalBase.py (synapse.evalBase.py) An importable script that adds a library of helpful
routines for use with the Synapse evaluation boards.
Board detection, GPIO programming, and relay control
are just a few examples
EvalHeartBeat.py Example of displaying multiple networking parameters
about a node on a single seven-segment display
gpsNmea.py Example decoding of data from a serial GPS
SNAP Reference Manual Document Number 600-0007K Page 107 of 202