Advertisement
Guest User

Untitled

a guest
Sep 20th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. //transmitter
  2.  
  3. #include <RS485_non_blocking.h>
  4. #include <SoftwareSerial.h>
  5. SoftwareSerial rsbus (2, 3); // receive pin, transmit pin
  6. const byte ENABLE_PIN = 4;
  7.  
  8. size_t fWrite (const byte what)
  9. {
  10. return rsbus.write (what);
  11. }
  12.  
  13. RS485 myChannel (NULL, NULL, fWrite, 0);
  14.  
  15. void setup ()
  16. {
  17. rsbus.begin (9600);
  18. myChannel.begin ();
  19. } // end of setup
  20.  
  21. const byte msg [] = "Hello world";
  22.  
  23.  
  24. void loop ()
  25. {
  26. digitalWrite (ENABLE_PIN, HIGH); // disable sending
  27. myChannel.sendMsg (msg, sizeof (msg));
  28. digitalWrite (ENABLE_PIN, LOW); // disable sending
  29. delay (1000);
  30. } // end of loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement