Last active
August 29, 2015 14:03
-
-
Save tprynn/3ee9cd7f748cbdff8926 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/********** | |
* SmartThings Arduino Shield Passthrough | |
* For use on Arduino Mega | |
* author: github.com/tprynn | |
* Attach Shield normally with switch on 2/3. | |
* Jumper pins: | |
* - 18 (Tx1) to Shield 3 (Rx) | |
* - 19 (Rx1) to Shield 2 (Tx) | |
**********/ | |
#define BUF_SIZE 512 | |
void setup() { | |
delay(1500); | |
Serial.begin(115200); | |
Serial1.begin(2400); | |
} | |
byte buffer[BUF_SIZE]; | |
int bytes; | |
void loop() { | |
if(Serial.available()) { | |
memset(buffer, 0, BUF_SIZE); | |
bytes = Serial.readBytes((char *)buffer, BUF_SIZE); | |
// local echo: | |
Serial.write(buffer, bytes); | |
Serial1.write(buffer, bytes); | |
} | |
if(Serial1.available()) { | |
memset(buffer, 0, BUF_SIZE); | |
bytes = Serial1.readBytes((char *)buffer, BUF_SIZE); | |
Serial.write(buffer, bytes); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment