CabBus simple example using CanBus Shield V01

Dependencies:   mbed

Revision:
0:5daadd838679
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jan 07 15:24:52 2019 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+
+Ticker ticker;
+DigitalOut led1(LED1);
+//The constructor takes in RX, and TX pin respectively.
+CAN can1(D10, D2);
+
+char counter = 0;
+
+void send() {
+    if(can1.write(CANMessage(1337, &counter, 1))) {
+        printf("Message sent: %d\r\n", counter);
+        counter++;
+    }
+    //led1 = !led1;
+}
+
+int main() {
+   ticker.attach(&send, 1);
+   CANMessage msg;
+    while(1) {
+        if(can1.read(msg)) {
+            printf("Message received: %d\r\n", msg.data[0]);
+            led1 = !led1;
+        }
+        wait(0.1);
+        
+    }
+}