Created
October 8, 2019 11:26
-
-
Save RobolinkAkademi/61cf35525c4cd90dba5aace57702d7c0 to your computer and use it in GitHub Desktop.
Arduino_mcp2515_canbus-spi_transmitter
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 <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