Last active
December 20, 2015 07:39
-
-
Save theycallmeswift/6095051 to your computer and use it in GitHub Desktop.
BreakfastSerial Code Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int led = 13; | |
void setup() { | |
pinMode(led, OUTPUT); | |
} | |
void loop() { | |
digitalWrite(led, HIGH); | |
delay(1000); | |
digitalWrite(led, LOW); | |
delay(1000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from BreakfastSerial import Arduino, Led | |
board = Arduino() | |
led = Led(board, 13) | |
led.blink(1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment