Python and Arduino
Álvaro Justen aka Turicas
EuroSciPy 2012
Lightning Talks
26/08/2012
Álvaro Justen aka Turicas
EuroSciPy 2012
Lightning Talks
26/08/2012
{twitter.com,
github.com,
youtube.com
}/turicas
turicas.info
alvaro@CursoDeArduino.com.br
www.CursoDeArduino.com.br
emap.fgv.br
Talk is cheap, show me the code!
#define LED 13 void setup() { pinMode(LED, OUTPUT); } void loop() { digitalWrite(LED, HIGH); //on delay(1000); //1000 ms = 1s digitalWrite(LED, LOW); //off delay(1000); //1000 ms = 1s }
# aptitude install python-serial
#define LED 13 void setup() { pinMode(LED, OUTPUT); Serial.begin(9600); } void loop() { if (Serial.available()) { char c = Serial.read(); if (c == 'H') { digitalWrite(LED, HIGH); } else if (c == 'L') { digitalWrite(LED, LOW); } } }
#!/usr/bin/env python import serial import time # /dev/ttyACM0 = Arduino Uno on Linux arduino = serial.Serial('/dev/ttyACM0', 9600) time.sleep(2) #waiting the initialization... arduino.write('H') #turns LED *on* time.sleep(3) #zzz arduino.write('L') #turns LED *off* time.sleep(3) #zzz arduino.close() #let's say goodbye
#define SENSOR A0 //analog pin 0 #define INTERVAL 100 //ms between measures void setup() { Serial.begin(9600); } void loop() { int measure = analogRead(SENSOR); Serial.println(measure); delay(INTERVAL); }
?
I'll be @ PyPLN's poster
{twitter.com,
github.com,
bitbucket.org,
youtube.com
}/turicas
turicas.info
alvaro@CursoDeArduino.com.br
www.CursoDeArduino.com.br