Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
52 views

Python and Arduino A Tale of Snakes and Kings

This document discusses using Python and Arduino together. It introduces Arduino as an easy to use and inexpensive hardware platform that can be controlled with Python using various libraries and protocols. Examples are given of sending simple ASCII messages, using the Firmata protocol, and embedding Python on an Arduino microcontroller chip to allow full Python programs to run on the device.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Python and Arduino A Tale of Snakes and Kings

This document discusses using Python and Arduino together. It introduces Arduino as an easy to use and inexpensive hardware platform that can be controlled with Python using various libraries and protocols. Examples are given of sending simple ASCII messages, using the Firmata protocol, and embedding Python on an Arduino microcontroller chip to allow full Python programs to run on the device.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

PYTHON AND ARDUINO: A TALE OF SNAKES AND KINGS

EuroPython 2012 - Florence

Alessandro Pasotti
a.pasotti@itopen.it
@elpaso

License: Creative Commons Attribution - Share Alike 3.0

Davide Corio
davide.corio@domsense.com
@davidecorio

Introduction
who
why
what

In the beginning
In the beginning was the abacus...
Technology started on real things
you could touch

Being digital
From Big-Blue to Micro-Soft

Touching the Sky


Alice in Metaphorsland:
desktops, trash-bins and wizards

Leaving Earth
Abstraction can be
addictive

Unusable interfaces

It's all about Interactivity

Sniffing the stacktrace

Being real
Physical computing: low cost MCU's and
electronic components

Here comes the King


Arduino's revolution
minimal
easy to use
cheap
from artists
Made in Italy
open hardware

What's inside?
hw: device: electronic prototyping board
sw: bootloader
sw: libraries
sw: IDE
community
lot of manuals
lot of examples

The board
Arduino UNO

MCU
Atmega 328
RAM 2 KB
ROM 32 KB
EEPROM 1 KB
14 digital pins
6 PWM capable
6 analog inputs
Up to 16 MHz
avr-gcc

Power to the people!


1982 IBM 80286

Splitting the byte


Atmega 328
Registers and ports

Pins
Digital IO
PWM (digital)
Analog inputs

PWM (pulse width modulation)

Logical 0

255 levels

Logical 1

C programming

Programming
setup
loop
blink!

King's audience
Arduino talks and listens
serial
sensors
RF
ethernet

At the king's court


shields
clones

DIY Arduino
< 10

Snake's attack
ASCII messages
compact protocols

a
-D
t
:
a
!
!
rm orks
i
f
y
p
w
t
t
r
i
o
,
p
m " y eah
i
>
>> print
>>>

"

ASCII snake
>>> import serial
>>> ser = serial.Serial('/dev/ttyACM0', 9600)
>>> while 1:
... ser.readline()
'1 Hello world!\r\n'
'2 Hello world!\r\n'
'3 Hello world!\r\n'

>>> import serial


>>> ser = serial.Serial('/dev/ttyACM0', 9600)
>>> ser.write('5')

The firmata protocol


http://firmata.org/wiki/Main_Page

pyfirmata to the rescue


https://bitbucket.org/tino/pyfirmata/src

PyFirmata example

Embedded snakes
Python on a chip
http://code.google.com/p/python-on-a-chip/

Other projects
Python Arduino Prototyping API
https://github.com/HashNuke/Python-Arduino-Prototyping-API
Python 2B (ASCII protocol)
http://arduino.cc/playground/Code/2B

OpenERP arduino controller


Demo

https://github.com/elpaso/arduinocontroller
http://www.youtube.com/watch?feature=player_embedded&v=MkxK9bHPZxQ

THANKS!

Alessandro Pasotti
a.pasotti@itopen.it
@elpaso

License: Creative Commons Attribution - Share Alike 3.0

Davide Corio
davide.corio@domsense.com
@davidecorio

You might also like