From bb234573de372618ea71b266a2019443fa05ad98 Mon Sep 17 00:00:00 2001 From: Divyansh Date: Wed, 25 Mar 2020 11:17:38 +0530 Subject: [PATCH 1/7] callibrate example for Servo --- examples/Callibration/Callibration.ino | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 examples/Callibration/Callibration.ino diff --git a/examples/Callibration/Callibration.ino b/examples/Callibration/Callibration.ino new file mode 100644 index 0000000..b7398b4 --- /dev/null +++ b/examples/Callibration/Callibration.ino @@ -0,0 +1,21 @@ +#include +Servo myservo; // create servo object to control a servo +int input; // variable to read the value from the SerialMonitor +int servoPin = 11; // set the Pin on Arduino, servo is attached + + +void setup() { + myservo.attach(servoPin); // attaches the servo on servoPin to the servo object + Serial.begin(9600); +} + +void loop() { +if (Serial.available() > 0) { + input = Serial.parseInt(); // reads the value from Serial + myservo.write(input); // sets the servo position + Serial.print("Servo set to "); + Serial.print(input); + Serial.println(" degree"); + delay (1000); + } +} From 60017535103a4fdd07a26f9103cbcc288c4ae453 Mon Sep 17 00:00:00 2001 From: Divyansh Date: Wed, 25 Mar 2020 11:22:40 +0530 Subject: [PATCH 2/7] calibrate example for servo --- .../{Callibration/Callibration.ino => Calibrate/Calibrate.ino} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{Callibration/Callibration.ino => Calibrate/Calibrate.ino} (100%) diff --git a/examples/Callibration/Callibration.ino b/examples/Calibrate/Calibrate.ino similarity index 100% rename from examples/Callibration/Callibration.ino rename to examples/Calibrate/Calibrate.ino From 4b31d2e4cb8a9d1e995edd79e7ea4c2abbb07f37 Mon Sep 17 00:00:00 2001 From: Divyansh Date: Wed, 25 Mar 2020 14:17:46 +0530 Subject: [PATCH 3/7] changes requested --- examples/Calibrate/Calibrate.ino | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/examples/Calibrate/Calibrate.ino b/examples/Calibrate/Calibrate.ino index b7398b4..addfe48 100644 --- a/examples/Calibrate/Calibrate.ino +++ b/examples/Calibrate/Calibrate.ino @@ -1,7 +1,17 @@ +/* Calibrate +This code allows to calibrate your servo motor using the serial monitor +Enter the degree in the serial monitor + by Divyansh Khandelwal + This example code is in the public domain. + + modified 24th March 2020 + by Divyansh Khandelwal +*/ + #include Servo myservo; // create servo object to control a servo -int input; // variable to read the value from the SerialMonitor -int servoPin = 11; // set the Pin on Arduino, servo is attached +int input; // variable to read the value from the Serial Monitor +int servoPin = 11; // the Arduino pin the servo is attached to void setup() { From a928daa887cda59055234e025889665c83271b8c Mon Sep 17 00:00:00 2001 From: Divyansh Date: Wed, 25 Mar 2020 15:08:36 +0530 Subject: [PATCH 4/7] bug fix for serial monitor --- examples/Calibrate/Calibrate.ino | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/Calibrate/Calibrate.ino b/examples/Calibrate/Calibrate.ino index addfe48..6784311 100644 --- a/examples/Calibrate/Calibrate.ino +++ b/examples/Calibrate/Calibrate.ino @@ -17,15 +17,20 @@ int servoPin = 11; // the Arduino pin the servo is attached to void setup() { myservo.attach(servoPin); // attaches the servo on servoPin to the servo object Serial.begin(9600); + Serial.println("Enter The Angle from 0 to 180"); } void loop() { -if (Serial.available() > 0) { + if (Serial.available() > 0) { input = Serial.parseInt(); // reads the value from Serial + while (Serial.available()) { // remove the line endings + Serial.read(); + } myservo.write(input); // sets the servo position + delay (50); Serial.print("Servo set to "); Serial.print(input); Serial.println(" degree"); - delay (1000); + } } From e69088d3e7fae7ede0752d652af86ac7fbb87fc2 Mon Sep 17 00:00:00 2001 From: Divyansh Date: Wed, 25 Mar 2020 15:10:11 +0530 Subject: [PATCH 5/7] Auto Format implement --- examples/Calibrate/Calibrate.ino | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/Calibrate/Calibrate.ino b/examples/Calibrate/Calibrate.ino index 6784311..84ebf24 100644 --- a/examples/Calibrate/Calibrate.ino +++ b/examples/Calibrate/Calibrate.ino @@ -1,16 +1,16 @@ /* Calibrate -This code allows to calibrate your servo motor using the serial monitor -Enter the degree in the serial monitor - by Divyansh Khandelwal - This example code is in the public domain. + This code allows to calibrate your servo motor using the serial monitor + Enter the degree in the serial monitor + by Divyansh Khandelwal + This example code is in the public domain. - modified 24th March 2020 - by Divyansh Khandelwal + modified 24th March 2020 + by Divyansh Khandelwal */ #include Servo myservo; // create servo object to control a servo -int input; // variable to read the value from the Serial Monitor +int input; // variable to read the value from the Serial Monitor int servoPin = 11; // the Arduino pin the servo is attached to @@ -26,11 +26,11 @@ void loop() { while (Serial.available()) { // remove the line endings Serial.read(); } - myservo.write(input); // sets the servo position + myservo.write(input); // sets the servo position delay (50); Serial.print("Servo set to "); Serial.print(input); Serial.println(" degree"); - + } } From 881950227a4ae972a2d529b21e03c4ddbcb2cd21 Mon Sep 17 00:00:00 2001 From: Divyansh Date: Wed, 25 Mar 2020 23:12:56 +0530 Subject: [PATCH 6/7] bug fix for both Newline and carriage return --- examples/Calibrate/Calibrate.ino | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/Calibrate/Calibrate.ino b/examples/Calibrate/Calibrate.ino index 84ebf24..28a3dc5 100644 --- a/examples/Calibrate/Calibrate.ino +++ b/examples/Calibrate/Calibrate.ino @@ -1,5 +1,5 @@ /* Calibrate - This code allows to calibrate your servo motor using the serial monitor + This code allows you to calibrate your servo motor using the serial monitor Enter the degree in the serial monitor by Divyansh Khandelwal This example code is in the public domain. @@ -23,11 +23,12 @@ void setup() { void loop() { if (Serial.available() > 0) { input = Serial.parseInt(); // reads the value from Serial + delay(25); while (Serial.available()) { // remove the line endings Serial.read(); } myservo.write(input); // sets the servo position - delay (50); + delay (25); Serial.print("Servo set to "); Serial.print(input); Serial.println(" degree"); From be98aac120dfb581e248efbe9d7c85d93e667652 Mon Sep 17 00:00:00 2001 From: Divyansh Date: Wed, 25 Mar 2020 23:16:07 +0530 Subject: [PATCH 7/7] suggestions considered --- examples/Calibrate/Calibrate.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Calibrate/Calibrate.ino b/examples/Calibrate/Calibrate.ino index 28a3dc5..b57648e 100644 --- a/examples/Calibrate/Calibrate.ino +++ b/examples/Calibrate/Calibrate.ino @@ -1,6 +1,6 @@ /* Calibrate This code allows you to calibrate your servo motor using the serial monitor - Enter the degree in the serial monitor + Enter the angle in the serial monitor by Divyansh Khandelwal This example code is in the public domain.