https://www.amazon.it/gp/product/B082B9JKH1/ref=ppx_yo_dt_b_asin_title_o08_s02?ie=UTF8&psc=1
How do i connect these to a teensy 3.2 please?
Yes newb )
How do i connect these to a teensy 3.2 please?
Yes newb )
Here is the code that worked succesfully for me with that particular CAN board:How do i connect these to a teensy 3.2 please?
// https://en.wikipedia.org/wiki/CAN_bus
// library needed: https://github.com/autowp/arduino-mcp2515
// Signal Teensy pins MCP2515 pins
// Vcc 5V VCC
// GND GND GND
// SPI SS 10 CS
// SPI MOSI 11 SO
// SPI MISO 12 SI
// SPI SCK 13 SCK
// CANL - L
// CANH - H
#include <SPI.h>
#include <mcp2515.h>
struct can_frame canMsg1;
struct can_frame canMsg2;
MCP2515 mcp2515(10);
void setup() {
canMsg1.can_id = 0x0F6;
canMsg1.can_dlc = 8;
canMsg1.data[0] = 0x8E;
canMsg1.data[1] = 0x87;
canMsg1.data[2] = 0x32;
canMsg1.data[3] = 0xFA;
canMsg1.data[4] = 0x26;
canMsg1.data[5] = 0x8E;
canMsg1.data[6] = 0xBE;
canMsg1.data[7] = 0x86;
canMsg2.can_id = 0x036;
canMsg2.can_dlc = 8;
canMsg2.data[0] = 0x0E;
canMsg2.data[1] = 0x00;
canMsg2.data[2] = 0x00;
canMsg2.data[3] = 0x08;
canMsg2.data[4] = 0x01;
canMsg2.data[5] = 0x00;
canMsg2.data[6] = 0x00;
canMsg2.data[7] = 0xA0;
while (!Serial);
Serial.begin(115200);
mcp2515.reset();
mcp2515.setBitrate(CAN_500KBPS, MCP_8MHZ);
mcp2515.setNormalMode();
Serial.println("Example: Write to CAN");
}
void loop() {
mcp2515.sendMessage(&canMsg1);
mcp2515.sendMessage(&canMsg2);
Serial.println("Messages sent");
delay(100);
}