Created
June 2, 2017 09:45
-
-
Save illustris/c76418202ad70449e4d0ffc3d40873dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <FlexCAN.h> | |
#include <kinetis_flexcan.h> | |
int led = 13; | |
// create CAN object | |
FlexCAN CANReceiver(500000); | |
static CAN_message_t msg; | |
void setup() { | |
// init CAN bus | |
CANReceiver.begin(); | |
pinMode(led, OUTPUT); | |
delay(1000); | |
Serial1.println("CAN Receiver Initialized"); | |
} | |
void loop() { | |
while( CANReceiver.read(msg)) { | |
// toggle LEDs | |
digitalWrite(led, !digitalRead(led)); | |
Serial1.print("Receiving: "); | |
for(int i=0; i<msg.len; i++) { | |
Serial1.print(msg.buf[i]); Serial1.print(" "); | |
} | |
Serial.println(""); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment