Created
September 23, 2014 07:52
-
-
Save blakejakopovic/c2bd80b21e7ef097b997 to your computer and use it in GitHub Desktop.
Spark Core Sketch for testing Firmata over TCP server
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 "firmata-spark/firmata-spark.h" | |
TCPServer server = TCPServer(5678); | |
TCPClient client; | |
bool new_client = true; | |
void setup() | |
{ | |
// start listening for clients | |
server.begin(); | |
// Make sure your Serial Terminal app is closed before powering your Core | |
Serial.begin(9600); | |
// Now open your Serial Terminal, and hit any key to continue! | |
while(!Serial.available()) SPARK_WLAN_Loop(); | |
Serial.println(WiFi.localIP()); | |
// Serial.println(WiFi.subnetMask()); | |
// Serial.println(WiFi.gatewayIP()); | |
// Serial.println(WiFi.SSID()); | |
} | |
void loop() | |
{ | |
if (client.connected()) | |
{ | |
if (new_client) | |
{ | |
Firmata.begin(client); | |
new_client = false; | |
Serial.println("New client connected"); | |
} | |
Serial.println("> Hello world"); | |
Firmata.sendString("Hello world"); | |
delay(10); | |
} else { | |
new_client = true; | |
client = server.available(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment