Advertisement
jtentor

Tunnel Sample for Arduino

Aug 2nd, 2017
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. /**
  2.  * Include headers
  3.  */
  4. #include <SoftwareSerial.h>
  5.  
  6. SoftwareSerial Tunnel(10, 11); // RX, TX
  7. byte data;
  8.  
  9. /**
  10.  * Arduino default setup function, runs only once when the device is turned on
  11.  */
  12. void setup() {
  13.     Tunnel.begin(9600);
  14.     Serial.begin(9600);
  15.     Serial.println(F("// ---- Tunnel 9600"));
  16. }
  17.  
  18. /**
  19.  * Arduino default loop function, always runs until device turns off
  20.  */
  21. void loop() {
  22.     if (Tunnel.available() > 0) {
  23.         data = Tunnel.read();
  24.         Serial.write(data);
  25.     }
  26.     if (Serial.available() > 0) {
  27.         data = Serial.read();
  28.         Tunnel.write(data);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement