diff --git a/examples/Braccio_LearnByDoing/Braccio_LearnByDoing.ino b/examples/Braccio_LearnByDoing/Braccio_LearnByDoing.ino index 3015f39..3cc189d 100644 --- a/examples/Braccio_LearnByDoing/Braccio_LearnByDoing.ino +++ b/examples/Braccio_LearnByDoing/Braccio_LearnByDoing.ino @@ -118,7 +118,7 @@ static mbed::FATFileSystem fs("fs"); void setup() { Serial.begin(115200); - while (!Serial) { } + for (auto const start = millis(); !Serial && ((millis() - start) < 5000); delay(10)) { } // Mount file system for load/store movements int err = fs.mount(&bd); @@ -126,12 +126,15 @@ void setup() err = fs.reformat(&bd); } - // Call Braccio.begin() for default menu or pass a function for custom menu - Braccio.begin(customMenu); + if (!Braccio.begin(customMenu)) { + if (Serial) Serial.println("Braccio.begin() failed."); + for(;;) { } + } Serial.println("Replicate a movement"); } -void loop() { +void loop() +{ if (state == LEARN) { Braccio.positions(idx); idx += 6; diff --git a/examples/LCD_Custom_Menu/LCD_Custom_Menu.ino b/examples/LCD_Custom_Menu/LCD_Custom_Menu.ino index c5c779b..18af02c 100644 --- a/examples/LCD_Custom_Menu/LCD_Custom_Menu.ino +++ b/examples/LCD_Custom_Menu/LCD_Custom_Menu.ino @@ -38,10 +38,18 @@ void customMenu(){ * SETUP/LOOP **************************************************************************************/ -void setup() { - Braccio.begin(customMenu); +void setup() +{ + Serial.begin(115200); + for (auto const start = millis(); !Serial && ((millis() - start) < 5000); delay(10)) { } + + if (!Braccio.begin(customMenu)) { + if (Serial) Serial.println("Braccio.begin() failed."); + for(;;) { } + } } -void loop() { +void loop() +{ } diff --git a/examples/LCD_Menu_Joystick/LCD_Menu_Joystick.ino b/examples/LCD_Menu_Joystick/LCD_Menu_Joystick.ino index fdab2fb..9a962ed 100644 --- a/examples/LCD_Menu_Joystick/LCD_Menu_Joystick.ino +++ b/examples/LCD_Menu_Joystick/LCD_Menu_Joystick.ino @@ -60,10 +60,18 @@ void customMenu(){ * SETUP/LOOP **************************************************************************************/ -void setup() { - Braccio.begin(customMenu); +void setup() +{ + Serial.begin(115200); + for (auto const start = millis(); !Serial && ((millis() - start) < 5000); delay(10)) { } + + if (!Braccio.begin(customMenu)) { + if (Serial) Serial.println("Braccio.begin() failed."); + for(;;) { } + } } -void loop() { +void loop() +{ } diff --git a/examples/LCD_Motors/LCD_Motors.ino b/examples/LCD_Motors/LCD_Motors.ino index 3fee9b6..f3a0395 100644 --- a/examples/LCD_Motors/LCD_Motors.ino +++ b/examples/LCD_Motors/LCD_Motors.ino @@ -83,12 +83,19 @@ void customMenu() { * SETUP/LOOP **************************************************************************************/ -void setup() { - Braccio.begin(customMenu); +void setup() +{ Serial.begin(115200); + for (auto const start = millis(); !Serial && ((millis() - start) < 5000); delay(10)) { } + + if (!Braccio.begin(customMenu)) { + if (Serial) Serial.println("Braccio.begin() failed."); + for(;;) { } + } } -void loop() { +void loop() +{ for (float angle = 0.0; angle <= 180.0; angle+=10.0){ Braccio.move(selected_motor).to(angle); delay(500); diff --git a/examples/Tools/Factory_Set_Initial_Servo_Position/Factory_Set_Initial_Servo_Position.ino b/examples/Tools/Factory_Set_Initial_Servo_Position/Factory_Set_Initial_Servo_Position.ino index 473b9e1..32cbe3c 100644 --- a/examples/Tools/Factory_Set_Initial_Servo_Position/Factory_Set_Initial_Servo_Position.ino +++ b/examples/Tools/Factory_Set_Initial_Servo_Position/Factory_Set_Initial_Servo_Position.ino @@ -104,7 +104,11 @@ void setup() Serial.begin(115200); while(!Serial) { } - Braccio.begin(); + if (!Braccio.begin()) { + Serial.println("Braccio.begin() failed."); + for(;;) { } + } + Braccio.disengage(); for (auto & servo : INITIAL_SERVO_POSITION) diff --git a/examples/Tools/Test_Inputs/Test_Inputs.ino b/examples/Tools/Test_Inputs/Test_Inputs.ino index 9d2020f..ef937bb 100644 --- a/examples/Tools/Test_Inputs/Test_Inputs.ino +++ b/examples/Tools/Test_Inputs/Test_Inputs.ino @@ -9,9 +9,13 @@ void setup() { Serial.begin(115200); - while(!Serial){} + while(!Serial) { } + + if (!Braccio.begin()) { + Serial.println("Braccio.begin() failed."); + for(;;) { } + } - Braccio.begin(); Serial.println("Press any button or move the joystick."); } diff --git a/examples/Tools/Test_Motor_Angular_Control/Test_Motor_Angular_Control.ino b/examples/Tools/Test_Motor_Angular_Control/Test_Motor_Angular_Control.ino index 52e5c9c..bba4fd5 100644 --- a/examples/Tools/Test_Motor_Angular_Control/Test_Motor_Angular_Control.ino +++ b/examples/Tools/Test_Motor_Angular_Control/Test_Motor_Angular_Control.ino @@ -53,9 +53,13 @@ void test_motor(int const id) void setup() { Serial.begin(115200); - while(!Serial){} + while(!Serial) { } + + if (!Braccio.begin()) { + Serial.println("Braccio.begin() failed."); + for(;;) { } + } - Braccio.begin(); Serial.println("Testing motor angular movement!"); } diff --git a/examples/Tools/Test_Motor_Communication/Test_Motor_Communication.ino b/examples/Tools/Test_Motor_Communication/Test_Motor_Communication.ino index 5e7972b..a0eb7f5 100644 --- a/examples/Tools/Test_Motor_Communication/Test_Motor_Communication.ino +++ b/examples/Tools/Test_Motor_Communication/Test_Motor_Communication.ino @@ -10,7 +10,11 @@ void setup() Serial.begin(115200); while(!Serial) { } - Braccio.begin(); + if (!Braccio.begin()) { + Serial.println("Braccio.begin() failed."); + for(;;) { } + } + Serial.println("Testing motor communication!"); Serial.println("Choose motor 1 to 6 to test the connection"); Serial.print(">> ");