File tree Expand file tree Collapse file tree 8 files changed +61
-19
lines changed
Factory_Set_Initial_Servo_Position
Test_Motor_Angular_Control Expand file tree Collapse file tree 8 files changed +61
-19
lines changed Original file line number Diff line number Diff line change @@ -118,20 +118,23 @@ static mbed::FATFileSystem fs("fs");
118118void setup ()
119119{
120120 Serial.begin (115200 );
121- while ( !Serial) { }
121+ for ( auto const start = millis (); !Serial && (( millis () - start) < 5000 ); delay ( 10 ) ) { }
122122
123123 // Mount file system for load/store movements
124124 int err = fs.mount (&bd);
125125 if (err) {
126126 err = fs.reformat (&bd);
127127 }
128128
129- // Call Braccio.begin() for default menu or pass a function for custom menu
130- Braccio.begin (customMenu);
129+ if (!Braccio.begin (customMenu)) {
130+ if (Serial) Serial.println (" Braccio.begin() failed." );
131+ for (;;) { }
132+ }
131133 Serial.println (" Replicate a movement" );
132134}
133135
134- void loop () {
136+ void loop ()
137+ {
135138 if (state == LEARN) {
136139 Braccio.positions (idx);
137140 idx += 6 ;
Original file line number Diff line number Diff line change @@ -38,10 +38,18 @@ void customMenu(){
3838 * SETUP/LOOP
3939 **************************************************************************************/
4040
41- void setup () {
42- Braccio.begin (customMenu);
41+ void setup ()
42+ {
43+ Serial.begin (115200 );
44+ for (auto const start = millis (); !Serial && ((millis () - start) < 5000 ); delay (10 )) { }
45+
46+ if (!Braccio.begin (customMenu)) {
47+ if (Serial) Serial.println (" Braccio.begin() failed." );
48+ for (;;) { }
49+ }
4350}
4451
45- void loop () {
52+ void loop ()
53+ {
4654
4755}
Original file line number Diff line number Diff line change @@ -60,10 +60,18 @@ void customMenu(){
6060 * SETUP/LOOP
6161 **************************************************************************************/
6262
63- void setup () {
64- Braccio.begin (customMenu);
63+ void setup ()
64+ {
65+ Serial.begin (115200 );
66+ for (auto const start = millis (); !Serial && ((millis () - start) < 5000 ); delay (10 )) { }
67+
68+ if (!Braccio.begin (customMenu)) {
69+ if (Serial) Serial.println (" Braccio.begin() failed." );
70+ for (;;) { }
71+ }
6572}
6673
67- void loop () {
74+ void loop ()
75+ {
6876
6977}
Original file line number Diff line number Diff line change @@ -83,12 +83,19 @@ void customMenu() {
8383 * SETUP/LOOP
8484 **************************************************************************************/
8585
86- void setup () {
87- Braccio. begin (customMenu);
86+ void setup ()
87+ {
8888 Serial.begin (115200 );
89+ for (auto const start = millis (); !Serial && ((millis () - start) < 5000 ); delay (10 )) { }
90+
91+ if (!Braccio.begin (customMenu)) {
92+ if (Serial) Serial.println (" Braccio.begin() failed." );
93+ for (;;) { }
94+ }
8995}
9096
91- void loop () {
97+ void loop ()
98+ {
9299 for (float angle = 0.0 ; angle <= 180.0 ; angle+=10.0 ){
93100 Braccio.move (selected_motor).to (angle);
94101 delay (500 );
Original file line number Diff line number Diff line change @@ -104,7 +104,11 @@ void setup()
104104 Serial.begin (115200 );
105105 while (!Serial) { }
106106
107- Braccio.begin ();
107+ if (!Braccio.begin ()) {
108+ Serial.println (" Braccio.begin() failed." );
109+ for (;;) { }
110+ }
111+
108112 Braccio.disengage ();
109113
110114 for (auto & servo : INITIAL_SERVO_POSITION)
Original file line number Diff line number Diff line change 99void setup ()
1010{
1111 Serial.begin (115200 );
12- while (!Serial){}
12+ while (!Serial) { }
13+
14+ if (!Braccio.begin ()) {
15+ Serial.println (" Braccio.begin() failed." );
16+ for (;;) { }
17+ }
1318
14- Braccio.begin ();
1519 Serial.println (" Press any button or move the joystick." );
1620}
1721
Original file line number Diff line number Diff line change @@ -53,9 +53,13 @@ void test_motor(int const id)
5353void setup ()
5454{
5555 Serial.begin (115200 );
56- while (!Serial){}
56+ while (!Serial) { }
57+
58+ if (!Braccio.begin ()) {
59+ Serial.println (" Braccio.begin() failed." );
60+ for (;;) { }
61+ }
5762
58- Braccio.begin ();
5963 Serial.println (" Testing motor angular movement!" );
6064}
6165
Original file line number Diff line number Diff line change @@ -10,7 +10,11 @@ void setup()
1010 Serial.begin (115200 );
1111 while (!Serial) { }
1212
13- Braccio.begin ();
13+ if (!Braccio.begin ()) {
14+ Serial.println (" Braccio.begin() failed." );
15+ for (;;) { }
16+ }
17+
1418 Serial.println (" Testing motor communication!" );
1519 Serial.println (" Choose motor 1 to 6 to test the connection" );
1620 Serial.print (" >> " );
You can’t perform that action at this time.
0 commit comments