Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Arduino_mcp2515_canbus-spi_transmitter
#include <mcp_can.h>
#include <SPI.h>
#define buton 8
#define SPI_CS_PIN 9
const int ledHIGH = 1;
const int ledLOW = 0;
unsigned char Led_Yak[8] = {ledHIGH, 1, 2, 3,4,5,6,7};
unsigned char Led_Sondur[8] = {ledLOW, 1, 2, 3,4,5,6,7};
MCP_CAN CAN(SPI_CS_PIN);
void setup()
{
Serial.begin(9600);
pinMode(buton, INPUT);
while (CAN_OK != CAN.begin(CAN_500KBPS))//can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield Baslatma Hatası");
Serial.println("CAN BUS Shield Tekrar Baslatılıyor...");
delay(100);
}
Serial.println("CAN BUS Shield Baslatması Basarılı!");
}
void loop()
{
Serial.println("In loop"); // send data: id = 0x70, standard frame, data len = 8, stmp: data buf
int buton_1 = digitalRead(buton);
if (buton_1 == HIGH)
{
CAN.sendMsgBuf(0x70, 0, 8, Led_Yak);
}
else if (buton_1 == LOW)
{
CAN.sendMsgBuf(0x70, 0, 8, Led_Sondur);
}
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.