Tag Archives: Processing programming language

Python Quick Reference

sys variables
argv                                                  Command line args
builtin_module_names         Linked C modules
byteorder                                     Native byte order
check_interval                           Signal check frequency
exec_prefix                                  Root directory
executable                                   Name of executable
exitfunc                                         Exit function name
modules                                        Loaded modules
path                                                 Search path
platform                                        Current platform
stdin, stdout, stderr                File objects for I/O
version_info                                Python version info
winver                                            Version number

sys.argv for $python map.py loc -c zip –h
sysargv[0]                                   map.py
sysargv[1]                                   loc
sysargv[2]                                   -c
sysargv[3]                                   zip
sysargv[4]                                   –h

os variables
altsep                                             Alternate sep
curdir                                             Current dir string
defpath                                         Default search path
devnull                                          Path of null device
extsep                                            Extension separator
linesep                                           Line separator
name                                               Name of OS
pardir                                             Parent dir string
pathsep                                         Path separator
sep                                                   Path separator

Class Special Methods
__init__(self, args)
__cmp__(self, other)
__getattr__(self, name)
__getattribute__(self, name)
__setattr__(self, name, attr)
__delattr__(self, name)
__call__(self, args, kwargs)
__lt__(self, other)
__le__(self, other)
__gt__(self, other)
__ge__(self, other)
__eq__(self, other)
__ne__(self, other)

String Methods
capitalize()                                  //locale dependent for 8-bit strings
count(sub, start, end)
find(sub, start, end)
index(sub, start, end)
isalnum()                                  //locale dependent for 8-bit strings
isalpha()                                   //locale dependent for 8-bit strings
isdigit()                                    //locale dependent for 8-bit strings
islower()                                 //locale dependent for 8-bit strings
isspace()                                 //locale dependent for 8-bit strings
istitle()                                    //locale dependent for 8-bit strings
isupper()                               //locale dependent for 8-bit strings
lower()                                   //locale dependent for 8-bit strings
replace(old, new)
rfind(sub, start, end)
rindex(sub, start, end)
swapcase()                        //locale dependent for 8-bit strings
title()                                   //locale dependent for 8-bit strings
upper()                              //locale dependent for 8-bit strings

List Methods
insert(position, item)

File Methods

Indexes and Slices (of a=[0,1,2,3,4,5])
len(a)               6
a[0]                   0
a[5]                   5
a[-1]                 5
a[-2]                 4
a[1:]                  [1,2,3,4,5]
a[:5]                  [0,1,2,3,4]
a[:-2]                [0,1,2,3]
a[1:3]               [1,2]
a[1:-1]             [1,2,3,4]
b=a[:]               Shallow copy of a

Datetime Methods
combine(date, time)
strptime(date, format)

Time Methods

Date Formatting (strftime and strptime)
%a                 Abbreviated weekday (Tues)
%A                Weekdday (Tuesday)
%b                 Abbreviated month name (Nov)
%B                Month name (November)
%c                 Date and Time
%d                Day (leading zeros) (01 to 31)
%H               24 hour (leading zeros) (00 to 23)
%I                 12 hour (leading zeros) (01 to 12)
%j                 Day of year (001 to 366)
%m              Month (01 to 12)
%M             Minute (00 to 59)
%p               AM or PM
%S               Second (00 to 61) //range takes account of leap and double
leap seconds
%U              Week number (00 to 53) //Sunday is start of week. All days
in a new year preceding the first Sunday are considered to
be in week 0.
%w              Weekday (0 to 6) //0 is Sunday, 6 is Saturday
%W             Week number (00 to 53) //Monday as start of week. All
days in a neew year preceding the first Monday are
considered to be in week 0.
%x                Date
%X               Time
%y                Year without century (00 to 99)
%Y               Year (2016)
%Z               Time zone (GMT)
%%              A literal “%” character (%)

Arduino: How To Make An LED Blink

In this tutorial we will make an LED (light emitting diode) blink at specific intervals.

Items you will need:

  • 1 Arduino (UNO or equivalent)
  • 1 USB cable
  • 1 Breadboard
  • 3 connection wires (preferably male-male breadboard jumper wires and in 3 different colors. In this tutorial we will use Black for Ground, Red for 5v and Yellow for Arduino output).
  • 1 LED (light emitting diode) – 5 mm; leg yes; color Red (633nm)
  • 1 330 Ω Resistor – tolerance ±5%; resistance 330Ω

Component notes:

  • Arduino – please refer to “What Is An Arduino?” https://www.sysrecon.com/?p=15
  • LED (light emitting diode) – Make sure the short leg, marked with a flat side goes into the negative position (-)
  • 330 Ω Resistor – The color bands should read Orange, Orange, Brown, Gold. The direction of the resistor when placed on the breadboard is irrelevant.

To determine which resistor to use, please check the chart below:

Resistor Color Chart


4 Band Resistor Calculator

 Some resistors have the color bands grouped together  close to one end. Hold the resistor with the closely grouped bands to your left and read the resistor from the left to the right. Also, the first band can’t be silver or gold.


The schematic of the circuit we will be creating is as follows:

Arduino Blink Basic Schematic

Arduino LED Blink Detailed Schematic

Our finished circuit will look as follows:

Arduino Blink Breadboard

  • LED GOES FROM D10(+ anode) TO D11(- cathode)
  • 333O Resistor GOES FROM B11 TO Anywhere on breadboard ground (- GND)
  • Black Jumper Wire GOES FROM Arduino GND TO Breadboard Ground(-)
  • Red Jumper Wire GOES FROM Arduino 5V TO Breadboard Power (+)
  • Yellow Jumper Wire GOES FROM Arduino PIN13 TO Breadboard E10

Now that the circuit is built, we can connect the Arduino to our computer. Once it is connected open up the Arduino Integrated Development Environment (IDE). Before we start adding the code, click on Tools → Board and select the correct Arduino board you are using. Next, click on Tools → Serial Port and select your correct port. Once the IDE is setup enter the code below either by typing, copy and paste or by downloading from https://www.sysrecon.com/downloads/arduino/blink.ino


Turns on an LED on for five seconds, then off for five seconds, repeatedly.

This example code is in the public domain.

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);

// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5000); // wait for 5 seconds
digitalWrite(led, LOW); // turn the LED off by making voltage LOW
delay(5000); // wait for 5 seconds

Once you have entered the code into the IDE, click verify to ensure the code compiles and then click upload to get the sketch onto your Arduino.

Arduino IDE Verify and Upload

After a few seconds the Arduino will restart and you will see the sketch begin to execute.

You should also notice that the Arduino has an LED on-board that will sync to your LED on the breadboard. If you do not have the components to create this circuit, you can still test the source code with the Arduino’s on-board LED.

We hope you enjoyed this Arduino tutorial. Keep checking back as there will be many more to come!

What Is An Arduino?

The Arduino was introduced in 2005 by founders Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and David Mellis. The Arduino is not really the board itself or the microprocessor on the board. The Arduino is a hardware/software platform that was designed to provide an inexpensive and easy way for hobbyists, students and professionals to create devices that interact with their environment. The Arduino platform is completely open hardware and open source software.

Arduino boards can be purchased pre-assembled or as do-it-yourself kits. The hardware design information is available for those who would like to assemble an Arduino by hand. The current prices of Arduino boards run around $20-$30 on SparkFun and clones as low as $9 on Amazon

The Arduino platform is a single-board microcontroller designed around an 8-bit Atmel AVR microcontroller, or a 32-bit Atmel ARM. Official Arduinos have used the megaAVR series of chips, specifically the ATmega8, ATmega168, ATmega328, ATmega1280, and ATmega2560. Most boards include a 5 volt linear regulator and a 16 MHz crystal oscillator.

The Arduino platfrom feature a USB interface, 6 analog input pins, as well as 14 digital I/O pins (six of which can produce pulse-width modulated signals) which allows the user to attach various interchangeable add-on modules known as shields or basic breadboards. Many shields are individually addressable via an I²C serial bus, allowing many shields to be stacked and used in parallel. Shields or jumper wires to a breadboard are plugged into the top of the board, via female 0.10-inch (2.5 mm) headers. The Arduino has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers

The Arduino’s microcontroller is also pre-programmed with a boot loader that simplifies uploading of programs to the on-chip flash memory, compared with other devices that typically need an external programmer. Arduino boards are programmed via USB over an RS-232 serial connection implemented using USB-to-serial adapter chips such as the FTDI FT232

The Arduino Platform comes with a simple down-loadable, cross-platform, integrated development environment (IDE) written in JAVA and allows users to write programs for Arduino using C or C++. The code you write is C/C++ syntax but not a valid C/C++ program. An extra include header at the top and a very simple main() function at the bottom, to make it a valid C++ program. The IDE is derived from the IDE for the Processing programming language and the Wiring development platform and contains a C/C++ library called “Wiring”. Wiring was based on the original work done on Processing project in MIT. The Wiring IDE uses the GNU toolchain and AVR Libc to compile programs, and uses avrdude to upload programs to the board. You can program the arduino in standard C using avrstudio and upload with avrdude.

Programming in the Arduino IDE is as simple as creating 2 functions()
1. setup() – a function run once at start up that can be used to define initial environment settings
2. loop() – a function called repeatedly until the board is powered off

A simple program to blink the Arduino LED

Turns on an LED on for one second, then off for one second, repeatedly.

This example code is in the public domain.

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);

// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second

We have hundreds of tutorials in mind for the Arduino Developemnt Platform. We will begin to produce them soon so keep checking back.

For more information right now, check out the offical Arduino page at https://arduino.cc be sure to check out the Arduino playground which has tons of information to get you started.