example code for Arduino Uno to connect ST-001


#include <SoftwareSerial.h> SoftwareSerial softSerial(8, 9); // Connect 8 to TX from ST-001, and GND - GND String inputSoftSerial = ""; String inputSerial = ""; void setup() { Serial.begin(115200); softSerial.begin(115200); pinMode(13, OUTPUT); // built in LED } void loop() { while (softSerial.available()) { char inChar = (char)softSerial.read(); inputSoftSerial += inChar; if (inChar == '\n') { handleInput(inputSoftSerial, "SoftSerial"); inputSoftSerial = ""; } } while (Serial.available()) { char inChar = (char)Serial.read(); inputSerial += inChar; if (inChar == '\n') { handleInput(inputSerial, "Serial"); inputSerial = ""; } } } void handleInput(String data, String source) { data.trim(); Serial.println("[" + source + "] received: " + data); if (data.indexOf("value:200") >= 0) { blinkLED(2); } else if (data.indexOf("value:100") >= 0) { blinkLED(1); } } void blinkLED(int times) { for (int i = 0; i < times; i++) { digitalWrite(13, HIGH); delay(200); digitalWrite(13, LOW); delay(200); } }