Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
Saturday Morning BreakfastSerial: Hacking Arduinos in Python (Swift)
PyCon Canada
August 14, 2013
Education
2
90
Saturday Morning BreakfastSerial: Hacking Arduinos in Python (Swift)
PyCon Canada
August 14, 2013
Tweet
Share
More Decks by PyCon Canada
See All by PyCon Canada
pyconca
2
470
pyconca
0
330
pyconca
0
160
pyconca
0
180
pyconca
0
68
pyconca
0
85
pyconca
0
910
pyconca
0
130
pyconca
2
77
Other Decks in Education
See All in Education
tradeglobalmarket
0
450
signer
0
290
hachama
0
170
matleenalaakso
0
310
agonagasukujira
PRO
0
150
taisso
1
970
kaityo256
0
160
signer
0
1k
kaityo256
0
290
youknowcast
0
170
yasulab
2
900
ceejeanpiaget
0
540
Featured
See All Featured
jensimmons
207
10k
kneath
219
15k
wjessup
339
16k
jrom
116
7.2k
62gerente
587
200k
chriscoyier
499
130k
kastner
54
1.9k
bermonpainter
342
26k
hatefulcrawdad
257
17k
jasonvnalue
82
8.1k
revolveconf
200
9.7k
samanthasiow
56
6.3k
Transcript
BREAKFAST SATURDAY MORNING SERIAL by @SwiftAlphaOne
Note: I’m not Ryan Gosling @SwiftAlphaOne
ARDUINO! Let’s talk about
Why are developers cuckoo for arduino?
SIMPLE API
Giraffe Add Tiger Head Tigeraffe Arduino is Open Source
None
EVERYWHERE Now Available
LOTS OF EXAMPLES
GR-R-REAT! Arduino is
1 2 3 4 USB Serial Port Ground & Power
Digital Pins Analog Pins ARDUINO 101
HELLO WORLD “ ”
Download the IDE http://arduino.cc/en/main/software
Wire up a LED
Blink 1: Arduino int led = 13; void setup() {
pinMode(led, OUTPUT); } void loop() { digitalWrite(led, HIGH); delay(1000); digitalWrite(led, LOW); delay(1000); }
Prototyping in C, Hey kids! is totally fun and easy.
“ ” - The Trix Rabbit
Friends don’t let Friends PROGRAM IN C.
THE INTERNETS? How do I talk to “ ”
#include <Ethernet.h> #include <SPI.h> EthernetClient client; String data = '{"foo":"bar"}';
void setup() { Ethernet.begin({0x90,0xA2,0xDA,0x00,0x55,0x8D}); } void loop() { if (client.connect("www.someapi.com",80)) { client.println("POST /api/v1/endpoints HTTP/1.1"); client.println("Host: www.someapi.com"); client.println("Content-Type: application/json"); client.print("Content-Length: "); client.println(data.length()); client.println(); client.print(data); client.println(); } }
#include <Ethernet.h> #include <SPI.h> EthernetClient client; String data = '{"foo":"bar"}';
void setup() { Ethernet.begin({0x90,0xA2,0xDA,0x00,0x55,0x8D}); } void loop() { if (client.connect("www.someapi.com",80)) { client.println("POST /api/v1/endpoints HTTP/1.1"); client.println("Host: www.someapi.com"); client.println("Content-Type: application/json"); client.print("Content-Length: "); client.println(data.length()); client.println(); client.print(data); client.println(); } } LOL
HORSEPOWER Limited .
A BETTER WAY! There must be
Feature Wishlist Language Agnostic Cross Platform Talks to the Internets
Complex Processing
FIRMATA http://firmata.org Follow your nose!
from pyfirmata import Arduino from time import sleep board =
Arduino('/dev/cu.usbmodem1411') ledPin = board.board.digital[13] while 1: ledPin.write(1) sleep(1) ledPin.write(0) sleep(1) Blink 2: pyFirmata
Johnny-Five ? Javascript Ruby Python
Cookies for breakfast!? Python ^
BREAKFASTSERIAL http://github.com/theycallmeswift/BreakfastSerial
$ pip install BreakfastSerial
from BreakfastSerial import Arduino, Led board = Arduino() led =
Led(board, 13) led.blink(1000) Blink 3: BreakfastSerial
None
Feature Wishlist Language Agnostic Cross Platform Talks to the Internets
Complex Processing
Language Agnostic Cross Platform Talks to the
Internets Complex Processing Feature Wishlist
Buttons, LEDs, & Sensors. “ ” Servos & buzzers too.
Lots of new components, added by devs like you!
SRSLY THO, I ACCEPT PULLS http://github.com/theycallmeswift/BreakfastSerial
M OAR!
ARDUINO.IO No, really. It’s coming. Go sign up. http://arduino.io
THANK YOU @SwiftAlphaOne theycallmeswift.com