Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Saturday Morning BreakfastSerial: Hacking Ardui...

Saturday Morning BreakfastSerial: Hacking Arduinos in Python (Swift)

PyCon Canada

August 14, 2013
Tweet

More Decks by PyCon Canada

Other Decks in Education

Transcript

  1. 1 2 3 4 USB Serial Port Ground & Power

    Digital Pins Analog Pins ARDUINO 101
  2. Blink 1: Arduino int led = 13; void setup() {

    pinMode(led, OUTPUT); } void loop() { digitalWrite(led, HIGH); delay(1000); digitalWrite(led, LOW); delay(1000); }
  3. #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(); } }
  4. #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
  5. 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
  6. from BreakfastSerial import Arduino, Led board = Arduino() led =

    Led(board, 13) led.blink(1000) Blink 3: BreakfastSerial
  7.  Language Agnostic  Cross Platform  Talks to the

    Internets  Complex Processing Feature Wishlist
  8. Buttons, LEDs, & Sensors. “ ” Servos & buzzers too.

    Lots of new components, added by devs like you!