Aivis3
5th November, 2019, 06:25 PM
Hi!
Arduino CAN bus, how to repeat message for example 20 times?
-----------------------------------------------------------------------------------------------------------------
#include <SPI.h>
#include <mcp_can.h>
const int spiCSPin = 10;
MCP_CAN CAN(spiCSPin);
void setup()
{
Serial.begin(115200);
while (CAN_OK != CAN.begin(CAN_125KBPS))
{
Serial.println("CAN BUS init Failed");
delay(100);
}
Serial.println("CAN BUS Shield Init OK!");
}
unsigned char msg1[8] = {0x51, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
void loop()
{
//for(int stmp=0; stmp<8; stmp++)
Serial.println("In loop");
CAN.sendMsgBuf(0x00000322, 1, 8, msg1);
delay(500);
//while(1);
}
------------------------------------------------------------------------------------------------------------------
Need to use While ? How...
Very need example please..
Thanks!
Arduino CAN bus, how to repeat message for example 20 times?
-----------------------------------------------------------------------------------------------------------------
#include <SPI.h>
#include <mcp_can.h>
const int spiCSPin = 10;
MCP_CAN CAN(spiCSPin);
void setup()
{
Serial.begin(115200);
while (CAN_OK != CAN.begin(CAN_125KBPS))
{
Serial.println("CAN BUS init Failed");
delay(100);
}
Serial.println("CAN BUS Shield Init OK!");
}
unsigned char msg1[8] = {0x51, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
void loop()
{
//for(int stmp=0; stmp<8; stmp++)
Serial.println("In loop");
CAN.sendMsgBuf(0x00000322, 1, 8, msg1);
delay(500);
//while(1);
}
------------------------------------------------------------------------------------------------------------------
Need to use While ? How...
Very need example please..
Thanks!