Skip to content

Instantly share code, notes, and snippets.

@AlexanderSavochkin
Created July 23, 2014 20:52
Show Gist options
  • Save AlexanderSavochkin/71255f1246d41258a34e to your computer and use it in GitHub Desktop.
Save AlexanderSavochkin/71255f1246d41258a34e to your computer and use it in GitHub Desktop.
Software serial interconnection
#include <SoftwareSerial.h>
SoftwareSerial softSerial(10, 11); // RX, TX
enum { LED_PIN = 13 };
void setup()
{
pinMode(LED_PIN, OUTPUT);
softSerial.begin(9600);
}
void loop()
{
if (softSerial.available()) //New data arrived
{
char command = softSerial.read();
switch (command)
{
case '1':
softSerial.println("Hello");
break;
case '2':
for (int i = 1; i < 5; ++i)
{
digitalWrite(LED_PIN, HIGH);
delay(50);
digitalWrite(LED_PIN, LOW);
delay(50);
}
break;
default:
softSerial.println('?'); //Not recognized commands
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment