Skip to content

Commit 009a341

Browse files
committed
autosync
1 parent bbb6fb8 commit 009a341

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

examples/SineWave/SineWave.ino

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,47 @@
22
#include <ODriveArduino.h>
33
#include <SoftwareSerial.h>
44

5-
SoftwareSerial odrive_serial(8, 9); // RX (ODrive TX), TX (ODrive RX)
5+
// Documentation for this example can be found here:
6+
// https://docs.odriverobotics.com/v/latest/guides/arduino-guide.html
7+
8+
9+
////////////////////////////////
10+
// Set up serial pins to the ODrive
11+
////////////////////////////////
12+
13+
// Below are some sample configurations.
14+
// You can comment out the default one and uncomment the one you wish to use.
15+
// You can of course use something different if you like
16+
// Don't forget to also connect ODrive ISOVDD and ISOGND to Arduino 3.3V/5V and GND.
17+
18+
// Arduino without spare serial ports (such as Arduino UNO) have to use software serial.
19+
// Note that this is implemented poorly and can lead to wrong data sent or read.
20+
// pin 8: RX - connect to ODrive TX
21+
// pin 9: TX - connect to ODrive RX
22+
SoftwareSerial odrive_serial(8, 9);
23+
int baudrate = 19200; // Must match what you configure on the ODrive (see docs for details)
24+
25+
// Teensy 3 and 4 (all versions) - Serial1
26+
// pin 0: RX - connect to ODrive TX
27+
// pin 1: TX - connect to ODrive RX
28+
// See https://www.pjrc.com/teensy/td_uart.html for other options on Teensy
29+
// HardwareSerial& odrive_serial = Serial1;
30+
// int baudrate = 115200; // Must match what you configure on the ODrive (see docs for details)
31+
32+
// Arduino Mega or Due - Serial1
33+
// pin 19: RX - connect to ODrive TX
34+
// pin 18: TX - connect to ODrive RX
35+
// See https://www.arduino.cc/reference/en/language/functions/communication/serial/ for other options
36+
// HardwareSerial& odrive_serial = Serial1;
37+
// int baudrate = 115200; // Must match what you configure on the ODrive (see docs for details)
38+
39+
640
ODriveArduino odrive(odrive_serial);
741

842
void setup() {
9-
// This baudrate must match the baudrate configured on the ODrive.
10-
// Note that the default ODrive baudrate is 115200, so this example requires
11-
// to change the baudrate on the ODrive accordingly (see docs for explanation),
12-
odrive_serial.begin(19200);
43+
odrive_serial.begin(baudrate);
1344

14-
Serial.begin(115200);
45+
Serial.begin(115200); // Serial to PC
1546

1647
delay(10);
1748

0 commit comments

Comments
 (0)