Skip to content

Commit c11356b

Browse files
ansonhexPillar1989
authored andcommitted
Clear up Arduino examples for all Arduino boards
1 parent 3ff9e1b commit c11356b

File tree

13 files changed

+162
-45
lines changed

13 files changed

+162
-45
lines changed

examples/OBDII_PIDs/OBDII_PIDs.ino

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,25 @@
2323
#define SERIAL Serial
2424
#endif
2525

26-
#define CAN_2518FD
27-
//#define CAN_2515
26+
#define CAN_2515
27+
// #define CAN_2518FD
28+
2829
// the cs pin of the version after v1.1 is default to D9
2930
// v0.9b and v1.0 is default D10
3031

32+
// Set SPI CS Pin according to your hardware
33+
// For Wio Terminal w/ MCP2518FD RPi Hat:
34+
// Channel 0 SPI_CS Pin: BCM 8
35+
// Channel 1 SPI_CS Pin: BCM 7
36+
// Interupt Pin: BCM25
37+
// *****************************************
38+
// For Arduino MCP2515 Hat:
39+
// SPI_CS Pin: D9
40+
3141

3242
#ifdef CAN_2518FD
3343
#include "mcp2518fd_can.h"
34-
const int SPI_CS_PIN = BCM8;
44+
const int SPI_CS_PIN = 9;
3545
mcp2518fd CAN(SPI_CS_PIN); // Set CS pin
3646
#endif
3747

examples/gpioRead/gpioRead.ino

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,22 @@
44
#include "mcp2515_can.h"
55
#include "mcp2518fd_can.h"
66

7-
#define CAN_2518FD
8-
#define SPI_CS_PIN BCM8
7+
#define CAN_2515
8+
// #define CAN_2518FD
9+
10+
// the cs pin of the version after v1.1 is default to D9
11+
// v0.9b and v1.0 is default D10
12+
13+
// Set SPI CS Pin according to your hardware
14+
// For Wio Terminal w/ MCP2518FD RPi Hat:
15+
// Channel 0 SPI_CS Pin: BCM 8
16+
// Channel 1 SPI_CS Pin: BCM 7
17+
// Interupt Pin: BCM25
18+
// *****************************************
19+
// For Arduino MCP2515 Hat:
20+
// SPI_CS Pin: D9
21+
22+
#define SPI_CS_PIN 9
923

1024
/*SAMD core*/
1125
#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE

examples/gpioWrite/gpioWrite.ino

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,23 @@
1111
#define SERIAL Serial
1212
#endif
1313

14-
#define CAN_2518FD
15-
#define SPI_CS_PIN BCM8
14+
15+
#define CAN_2515
16+
// #define CAN_2518FD
17+
18+
// the cs pin of the version after v1.1 is default to D9
19+
// v0.9b and v1.0 is default D10
20+
21+
// Set SPI CS Pin according to your hardware
22+
// For Wio Terminal w/ MCP2518FD RPi Hat:
23+
// Channel 0 SPI_CS Pin: BCM 8
24+
// Channel 1 SPI_CS Pin: BCM 7
25+
// Interupt Pin: BCM25
26+
// *****************************************
27+
// For Arduino MCP2515 Hat:
28+
// SPI_CS Pin: D9
29+
30+
#define SPI_CS_PIN 9
1631

1732
#ifdef CAN_2518FD
1833
mcp2518fd CAN(SPI_CS_PIN); // Set CS pin

examples/receive_Blink/receive_Blink.ino

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,24 @@
1212
#endif
1313

1414
#define CAN_2515
15-
//#define CAN_2518FD
15+
// #define CAN_2518FD
16+
1617
// the cs pin of the version after v1.1 is default to D9
1718
// v0.9b and v1.0 is default D10
1819

20+
// Set SPI CS Pin according to your hardware
21+
// For Wio Terminal w/ MCP2518FD RPi Hat:
22+
// Channel 0 SPI_CS Pin: BCM 8
23+
// Channel 1 SPI_CS Pin: BCM 7
24+
// Interupt Pin: BCM25
25+
// *****************************************
26+
// For Arduino MCP2515 Hat:
27+
// SPI_CS Pin: D9
28+
1929
#ifdef CAN_2518FD
2030
#include "mcp2518fd_can.h"
21-
const int SPI_CS_PIN = BCM8;
22-
const int CAN_INT_PIN = BCM25;
31+
const int SPI_CS_PIN = 9;
32+
const int CAN_INT_PIN = 2;
2333
mcp2518fd CAN(SPI_CS_PIN); // Set CS pin
2434
#endif
2535

examples/receive_check/receive_check.ino

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,25 @@
1111
#define SERIAL Serial
1212
#endif
1313

14-
//#define CAN_2515
15-
#define CAN_2518FD
14+
#define CAN_2515
15+
// #define CAN_2518FD
16+
1617
// the cs pin of the version after v1.1 is default to D9
1718
// v0.9b and v1.0 is default D10
1819

20+
// Set SPI CS Pin according to your hardware
21+
// For Wio Terminal w/ MCP2518FD RPi Hat:
22+
// Channel 0 SPI_CS Pin: BCM 8
23+
// Channel 1 SPI_CS Pin: BCM 7
24+
// Interupt Pin: BCM25
25+
// *****************************************
26+
// For Arduino MCP2515 Hat:
27+
// SPI_CS Pin: D9
28+
1929
#ifdef CAN_2518FD
2030
#include "mcp2518fd_can.h"
21-
const int SPI_CS_PIN = BCM8;
22-
const int CAN_INT_PIN = BCM25;
31+
const int SPI_CS_PIN = 9;
32+
const int CAN_INT_PIN = 2;
2333
mcp2518fd CAN(SPI_CS_PIN); // Set CS pin
2434
#endif
2535

examples/receive_interrupt/receive_interrupt.ino

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,24 @@
1212
#endif
1313

1414
#define CAN_2515
15-
//#define CAN_2518FD
15+
// #define CAN_2518FD
16+
1617
// the cs pin of the version after v1.1 is default to D9
1718
// v0.9b and v1.0 is default D10
1819

20+
// Set SPI CS Pin according to your hardware
21+
// For Wio Terminal w/ MCP2518FD RPi Hat:
22+
// Channel 0 SPI_CS Pin: BCM 8
23+
// Channel 1 SPI_CS Pin: BCM 7
24+
// Interupt Pin: BCM25
25+
// *****************************************
26+
// For Arduino MCP2515 Hat:
27+
// SPI_CS Pin: D9
1928

2029
#ifdef CAN_2518FD
2130
#include "mcp2518fd_can.h"
22-
const int SPI_CS_PIN = BCM8;
23-
const int CAN_INT_PIN = BCM25;
31+
const int SPI_CS_PIN = 9;
32+
const int CAN_INT_PIN = 2;
2433
mcp2518fd CAN(SPI_CS_PIN); // Set CS pin
2534
#endif
2635

examples/receive_interruptFD/receive_interruptFD.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
// the cs pin of the version after v1.1 is default to D9
1818
// v0.9b and v1.0 is default D10
19-
const int SPI_CS_PIN = BCM8;
20-
const int CAN_INT_PIN = BCM25;
19+
const int SPI_CS_PIN = 9;
20+
const int CAN_INT_PIN = 2;
2121

2222
#ifdef CAN_2518FD
2323
mcp2518fd CAN(SPI_CS_PIN); // Set CS pin

examples/recv_sd/recv_sd.ino

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,25 @@
1515

1616
File myFile;
1717

18-
//#define CAN_2515
19-
#define CAN_2518FD
18+
#define CAN_2515
19+
// #define CAN_2518FD
20+
2021
// the cs pin of the version after v1.1 is default to D9
2122
// v0.9b and v1.0 is default D10
2223

24+
// Set SPI CS Pin according to your hardware
25+
// For Wio Terminal w/ MCP2518FD RPi Hat:
26+
// Channel 0 SPI_CS Pin: BCM 8
27+
// Channel 1 SPI_CS Pin: BCM 7
28+
// Interupt Pin: BCM25
29+
// *****************************************
30+
// For Arduino MCP2515 Hat:
31+
// SPI_CS Pin: D9
2332

2433
#ifdef CAN_2518FD
2534
#include "mcp2518fd_can.h"
26-
const int SPI_CS_PIN = BCM8;
27-
const int CAN_INT_PIN = BCM25;
35+
const int SPI_CS_PIN = 9;
36+
const int CAN_INT_PIN = 2;
2837
mcp2518fd CAN(SPI_CS_PIN); // Set CS pin
2938
#endif
3039

examples/send/send.ino

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,25 @@
1212
#endif
1313

1414

15-
//#define CAN_2515
16-
#define CAN_2518FD
15+
#define CAN_2515
16+
// #define CAN_2518FD
17+
1718
// the cs pin of the version after v1.1 is default to D9
1819
// v0.9b and v1.0 is default D10
1920

21+
// Set SPI CS Pin according to your hardware
22+
// For Wio Terminal w/ MCP2518FD RPi Hat:
23+
// Channel 0 SPI_CS Pin: BCM 8
24+
// Channel 1 SPI_CS Pin: BCM 7
25+
// Interupt Pin: BCM25
26+
// *****************************************
27+
// For Arduino MCP2515 Hat:
28+
// SPI_CS Pin: D9
2029

2130
#ifdef CAN_2518FD
2231
#include "mcp2518fd_can.h"
23-
const int SPI_CS_PIN = BCM8;
24-
const int CAN_INT_PIN = BCM25;
32+
const int SPI_CS_PIN = 9;
33+
const int CAN_INT_PIN = 2;
2534
mcp2518fd CAN(SPI_CS_PIN); // Set CS pin
2635
#endif
2736

examples/sendFD/sendFD.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
#define SERIAL Serial
1313
#endif
1414

15-
1615
#define CAN_2518FD
1716
// the cs pin of the version after v1.1 is default to D9
1817
// v0.9b and v1.0 is default D10
19-
const int SPI_CS_PIN = BCM8;
18+
const int SPI_CS_PIN = 9;
2019

2120
#ifdef CAN_2518FD
2221
mcp2518fd CAN(SPI_CS_PIN); // Set CS pin
@@ -25,14 +24,15 @@ mcp2518fd CAN(SPI_CS_PIN); // Set CS pin
2524
void setup() {
2625
SERIAL.begin(115200);
2726
while(!Serial){};
28-
CAN.setMode(0);
27+
CAN.setMode(0); // Set FD Mode
2928
while (0 != CAN.begin((byte)CAN_500K_1M)) { // init can bus : baudrate = 500k
3029
SERIAL.println("CAN BUS Shield init fail");
3130
SERIAL.println(" Init CAN BUS Shield again");
3231
delay(100);
3332
}
3433
byte mode = CAN.getMode();
35-
SERIAL.printf("CAN BUS get mode = %d\n\r",mode);
34+
SERIAL.print("CAN BUS get mode = ");
35+
SERIAL.println(mode);
3636
SERIAL.println("CAN BUS Shield init ok!");
3737
}
3838

@@ -42,11 +42,11 @@ void loop() {
4242
stmp[63] = stmp[63] + 1;
4343
if (stmp[63] == 100) {
4444
stmp[63] = 0;
45-
stmp[63] = stmp[63] + 1;
45+
stmp[62] = stmp[62] + 1;
4646

47-
if (stmp[6] == 100) {
48-
stmp[6] = 0;
49-
stmp[5] = stmp[6] + 1;
47+
if (stmp[62] == 100) {
48+
stmp[62] = 0;
49+
stmp[61] = stmp[62] + 1;
5050
}
5151
}
5252

0 commit comments

Comments
 (0)