File tree Expand file tree Collapse file tree 2 files changed +48
-22
lines changed
Tools/Test_Motor_Angular_Control Expand file tree Collapse file tree 2 files changed +48
-22
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ /* This example demonstrates how to use the motor
2+ * API of the Braccio++ to directly control the
3+ * angle for each smart servo motor.
4+ */
5+
6+ #include < Braccio++.h>
7+
8+ void setup ()
9+ {
10+ Serial.begin (115200 );
11+ while (!Serial){}
12+
13+ /* Call Braccio.begin() for default menu
14+ * or pass a function for custom menu.
15+ */
16+ Braccio.begin ();
17+
18+ Serial.println (" Testing motor angular movement!" );
19+ }
20+
21+ void loop ()
22+ {
23+ Serial.println (" Choose motor to test (1 - 6):" );
24+ Serial.println (" >> " );
25+
26+ while ((Serial.available () <= 0 )) { }
27+ int const selected_motor = Serial.parseInt ();
28+ while (Serial.read () != ' \n ' ) { }
29+
30+ if (selected_motor < 1 || selected_motor > 6 ) {
31+ Serial.println (" Error, wrong motor id, choose motor id between 1 and 6" );
32+ return ;
33+ }
34+
35+ float const ANGLE_START = 0.0 ;
36+ float const ANGLE_STOP = 180.0 ;
37+ float const ANGLE_INCREMENT = 10.0 ;
38+
39+ for (float angle = ANGLE_START; angle <= ANGLE_STOP; angle += ANGLE_INCREMENT)
40+ {
41+ Braccio.move (selected_motor).to (angle);
42+ Serial.print (" Target angle: " + String (angle));
43+ Serial.print (" | " );
44+ Serial.print (" Current angle: " + String (Braccio.get (selected_motor).position ()));
45+ Serial.println ();
46+ delay (100 );
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments