You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can you add documentation on what hardware used? Especially for esp32 demo. I'm trying to make it work with arduino uno and mcp2515, so far couldn't figure it out.
I used this code
#include <SPI.h>
#include <mcp_can.h>
const int SPI_CS_PIN = 10;
MCP_CAN CAN(SPI_CS_PIN);
void setup() {
Serial.begin(115200);
while (CAN_OK != CAN.begin(MCP_ANY, CAN_1000KBPS, MCP_8MHZ)) {
Serial.println("CAN BUS initialization failed, retrying...");
delay(100);
}
Serial.println("CAN BUS initialized successfully");
}
void sendCanMessage(byte* data, int length) {
CAN.sendMsgBuf(0x070, 0, length, data);
delay(10); // Small delay to ensure message is sent
}
void loop() {
Serial.println("Sending commands");
// Enter "AT command mode"
byte atCommand[] = {0x41, 0x54, 0x2b, 0x41, 0x54, 0x0d, 0x0a};
sendCanMessage(atCommand, sizeof(atCommand));
delay(100); // Wait for command to be processed
Serial.println("Switched to at mode!");
// Rotate the motor forward for 1 second
byte forwardCommand[] = {0x41, 0x54, 0x90, 0x07, 0xeb, 0xfc, 0x08, 0x05, 0x70, 0x00, 0x00, 0x07, 0x01, 0x95, 0x54, 0x0d, 0x0a};
sendCanMessage(forwardCommand, sizeof(forwardCommand));
delay(1000);
// Stop the motor for 1 second
byte stopCommand[] = {0x41, 0x54, 0x90, 0x07, 0xeb, 0xfc, 0x08, 0x05, 0x70, 0x00, 0x00, 0x07, 0x00, 0x7f, 0xff, 0x0d, 0x0a};
sendCanMessage(stopCommand, sizeof(stopCommand));
delay(1000);
// Rotate the motor backward for 1 second
byte backwardCommand[] = {0x41, 0x54, 0x90, 0x07, 0xeb, 0xfc, 0x08, 0x05, 0x70, 0x00, 0x00, 0x07, 0x01, 0x6a, 0xaa, 0x0d, 0x0a};
sendCanMessage(backwardCommand, sizeof(backwardCommand));
delay(1000);
// Stop the motor for 1 second
sendCanMessage(stopCommand, sizeof(stopCommand));
delay(1000);
// Wait before repeating the sequence
delay(5000);
}
The text was updated successfully, but these errors were encountered:
Can you add documentation on what hardware used? Especially for esp32 demo. I'm trying to make it work with arduino uno and mcp2515, so far couldn't figure it out.
I used this code
The text was updated successfully, but these errors were encountered: