Last active
October 28, 2016 03:04
-
-
Save bavensky/20a9d12ad58415fe5a58ec27f6ae8ab5 to your computer and use it in GitHub Desktop.
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 <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