Advertisement
Guest User

Electric Imp Code

a guest
Jul 15th, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. function initUart()
  2. {
  3. hardware.configure(UART_57); // Using UART on pins 5 and 7
  4. hardware.uart57.configure(19200, 8, PARITY_NONE, 1, NO_CTSRTS, pollUart);     //Setting up a channel between Arduino and EI
  5. }
  6.  
  7. // UART polling function.
  8. function pollUart()
  9. {
  10. local s = "";
  11. local byte = hardware.uart57.read();
  12.  
  13. while(byte != -1) {
  14. s+=byte.tochar();
  15. byte = hardware.uart57.read();
  16. server.log("reading byte");
  17. }
  18.  
  19. if(s.len())server.show(s);
  20. if(s.len())server.log(s);
  21. }
  22.  
  23. function watchdog() {
  24.   imp.wakeup(5*60, watchdog);
  25.   server.log("watchdog");
  26. }
  27.  
  28. // Executing the functions
  29. imp.configure("RobotWireless", [Coordinate("Coordinates")], []);
  30. initUart(); // Initialize the UART, called just once
  31. watchdog();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement