Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <arduinoCAN.h>
  2. #include <arduinoClasses.h>
  3. #include <arduinoMultiprotocol.h>
  4. #include <arduinoUART.h>
  5. #include <arduinoUtils.h>
  6. #include <Wire.h>
  7. #include <SPI.h>
  8.  
  9. // Create an instance of the object
  10. CAN myCAN = CAN();
  11.  
  12. // Setting up our devices and I/Os
  13. void setup() {
  14. // Using the Socket 0 onto which Can bus module is plugged in
  15. Utils.setONSocket0();
  16. Utils.setMUXSocket0();
  17. // Initializes the UART
  18. Serial.begin(115200);
  19. delay(100);
  20.  
  21. myCAN.begin(500); // Start talking to the BUS. Speed= 500 Kbps
  22. }
  23.  
  24. void loop() {
  25. // 1. Receive data
  26.  
  27. if (myCAN.messageAvailable()) {
  28. // Read the last message received.
  29. myCAN.getMessage(&myCAN.messageRx);
  30. // Print in the serial monitor the received message
  31. myCAN.printMessage(&myCAN.messageRx);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement