Created
October 17, 2025 09:21
-
-
Save maxpromer/4a733d98527bfaff1a32c2d60db69bc1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /* | |
| * Adafruit MCP2515 FeatherWing CAN Sender Example | |
| */ | |
| #include <Adafruit_MCP2515.h> | |
| #define CS_PIN 10 | |
| #define CAN_BAUDRATE (250000) | |
| Adafruit_MCP2515 mcp(CS_PIN); | |
| void setup() { | |
| Serial.begin(115200); | |
| while(!Serial) delay(10); | |
| Serial.println("MCP2515 Sender test!"); | |
| if (!mcp.begin(CAN_BAUDRATE)) { | |
| Serial.println("Error initializing MCP2515."); | |
| while(1) delay(10); | |
| } | |
| Serial.println("MCP2515 chip found"); | |
| } | |
| void loop() { | |
| // send packet: id is 11 bits, packet can contain up to 8 bytes of data | |
| Serial.print("Sending packet ... "); | |
| mcp.beginPacket(0x12); | |
| mcp.write('h'); | |
| mcp.write('e'); | |
| mcp.write('l'); | |
| mcp.write('l'); | |
| mcp.write('o'); | |
| mcp.endPacket(); | |
| Serial.println("done"); | |
| delay(1000); | |
| // send extended packet: id is 29 bits, packet can contain up to 8 bytes of data | |
| Serial.print("Sending extended packet ... "); | |
| mcp.beginExtendedPacket(0xabcdef); | |
| mcp.write('w'); | |
| mcp.write('o'); | |
| mcp.write('r'); | |
| mcp.write('l'); | |
| mcp.write('d'); | |
| mcp.endPacket(); | |
| Serial.println("done"); | |
| delay(1000); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment