Smart-Home am Beispiel der Präsenzerkennung im Raum Projektarbeit Lennart Heimbs, Johannes Krug, Sebastian Dohle und Kevin Holzschuh bei Prof. Oliver Hofmann SS2019
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.

ReceiveTest.ino 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // AltSoftSerial Receive Test
  2. //
  3. // Transmit data with Serial1 and try to receive
  4. // it with AltSoftSerial. You must connect a wire
  5. // from Serial1 TX to AltSoftSerial RX.
  6. #include <AltSoftSerial.h>
  7. AltSoftSerial altser;
  8. const int mybaud = 9600;
  9. // Board Serial1 TX AltSoftSerial RX
  10. // ----- ---------- ----------------
  11. // Teensy 3.x 1 20
  12. // Teensy 2.0 8 (D3) 10 (C7)
  13. // Teensy++ 2.0 3 (D3) 4 (D4)
  14. // Arduino Leonardo 1 13
  15. // Arduino Mega 18 48
  16. // Serial1 on AVR @ 16 MHz minimum baud is 245
  17. // Serial1 on Teensy 3.2 @ 96 MHz minimum baud is 733
  18. // This example code is in the public domain.
  19. byte sentbyte;
  20. unsigned long prevmillis;
  21. byte testbyte=0xF0;
  22. void setup()
  23. {
  24. delay(200);
  25. Serial.begin(9600);
  26. while (!Serial) ; // wait for Arduino Serial Monitor
  27. Serial1.begin(mybaud); // connect a wire from TX1
  28. altser.begin(mybaud); // to AltSoftSerial RX
  29. Serial.println("AltSoftSerial Receive Test");
  30. prevmillis = millis();
  31. }
  32. void loop()
  33. {
  34. // transmit a test byte on Serial 1
  35. if (millis() - prevmillis > 250) {
  36. sentbyte = testbyte++;
  37. Serial1.write(sentbyte);
  38. prevmillis = millis();
  39. }
  40. // attempt to receive it by AltSoftSerial
  41. if (altser.available() > 0) {
  42. byte b = altser.read();
  43. Serial.println(b);
  44. if (b != sentbyte) {
  45. Serial.println("***** ERROR *****");
  46. }
  47. }
  48. }