Skip to content

Instantly share code, notes, and snippets.

@bavensky
Last active October 28, 2016 03:04
Show Gist options
  • Save bavensky/20a9d12ad58415fe5a58ec27f6ae8ab5 to your computer and use it in GitHub Desktop.
Save bavensky/20a9d12ad58415fe5a58ec27f6ae8ab5 to your computer and use it in GitHub Desktop.
#include <SoftwareSerial.h>
SoftwareSerial mySerial (2, 3); // RX,TX
int swL = 4;
int swR = 5;
int val = 0; // variable for reading the pin status
int val2 = 0;
int inByte;
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
pinMode(swR, INPUT); // declare push swicth as input
pinMode(swL, INPUT);
}
void loop()
{
if (mySerial.available() > 0) {
inByte = mySerial.read();
}
val = digitalRead(swL); // read input value
val2 = digitalRead(swR);
if (val == HIGH && val2 == HIGH) { //No push swicth
char inByte = 'S';
mySerial.write(inByte); // Send
}
else if (val == LOW && val2 == HIGH) {
char inByte = 'L';
mySerial.write(inByte); // Send
}
else if (val == HIGH && val2 == LOW) {
char inByte = 'R';
mySerial.write(inByte); // Send
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment