PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 satır
1.3KB

  1. /*
  2. Software serial multple serial test
  3. Receives from the hardware serial, sends to software serial.
  4. Receives from software serial, sends to hardware serial.
  5. The circuit:
  6. * RX is digital pin 10 (connect to TX of other device)
  7. * TX is digital pin 11 (connect to RX of other device)
  8. Note:
  9. Not all pins on the Mega and Mega 2560 support change interrupts,
  10. so only the following can be used for RX:
  11. 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
  12. Not all pins on the Leonardo support change interrupts,
  13. so only the following can be used for RX:
  14. 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
  15. created back in the mists of time
  16. modified 25 May 2012
  17. by Tom Igoe
  18. based on Mikal Hart's example
  19. This example code is in the public domain.
  20. */
  21. #include <SoftwareSerial.h>
  22. SoftwareSerial mySerial(10, 11); // RX, TX
  23. void setup()
  24. {
  25. // Open serial communications and wait for port to open:
  26. Serial.begin(57600);
  27. while (!Serial) {
  28. ; // wait for serial port to connect. Needed for Leonardo only
  29. }
  30. Serial.println("Goodnight moon!");
  31. // set the data rate for the SoftwareSerial port
  32. mySerial.begin(4800);
  33. mySerial.println("Hello, world?");
  34. }
  35. void loop() // run over and over
  36. {
  37. if (mySerial.available())
  38. Serial.write(mySerial.read());
  39. if (Serial.available())
  40. mySerial.write(Serial.read());
  41. }