Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Spark Core Firmata Example
#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");
} 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