From 13dc8234ea5d3fefa8281d835921f39dbc8a4931 Mon Sep 17 00:00:00 2001 From: jeeva2812 Date: Wed, 18 Mar 2020 18:43:12 +0530 Subject: [PATCH 1/4] Added an example --- examples/Read/Read.ino | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 examples/Read/Read.ino diff --git a/examples/Read/Read.ino b/examples/Read/Read.ino new file mode 100644 index 0000000..453573b --- /dev/null +++ b/examples/Read/Read.ino @@ -0,0 +1,38 @@ +/* Sweep + by BARRAGAN + This example code is in the public domain. + + modified 18 Mar 2020 + by S Jeeva + http://www.arduino.cc/en/Tutorial/Sweep +*/ + +#include + +Servo myservo; // create servo object to control a servo +// twelve servo objects can be created on most boards + +int pos = 0; // variable to store the servo position +int currPos; // variable to read the current position + +void setup() { + myservo.attach(9); // attaches the servo on pin 9 to the servo object + Serial.begin(9600); // Begin the Serial at 9600 baud rate +} + +void loop() { + for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees + // in steps of 1 degree + myservo.write(pos); // tell servo to go to position in variable 'pos' + delay(15); // waits 15ms for the servo to reach the position + currPos = myservo.read(); // Read the angle of position + Serial.println(currPos); // Print the angle of position in serial monitor + } + for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees + myservo.write(pos); // tell servo to go to position in variable 'pos' + delay(15); // waits 15ms for the servo to reach the position + currPos = myservo.read(); // Read the angle of position + Serial.println(currPos); // Print the angle of position in serial monitor + } +} + From 2fb080c0e7718a6c8a0d431c3f60fea39e00b24e Mon Sep 17 00:00:00 2001 From: S Jeeva <43230676+jeeva2812@users.noreply.github.com> Date: Thu, 19 Mar 2020 15:52:32 +0530 Subject: [PATCH 2/4] Update Read.ino --- examples/Read/Read.ino | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/Read/Read.ino b/examples/Read/Read.ino index 453573b..ad03060 100644 --- a/examples/Read/Read.ino +++ b/examples/Read/Read.ino @@ -4,7 +4,6 @@ modified 18 Mar 2020 by S Jeeva - http://www.arduino.cc/en/Tutorial/Sweep */ #include From ec1335dfa012b1f70a918f88c51af0ea7cb93b00 Mon Sep 17 00:00:00 2001 From: S Jeeva <43230676+jeeva2812@users.noreply.github.com> Date: Thu, 19 Mar 2020 15:53:09 +0530 Subject: [PATCH 3/4] Update Read.ino --- examples/Read/Read.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Read/Read.ino b/examples/Read/Read.ino index ad03060..3034836 100644 --- a/examples/Read/Read.ino +++ b/examples/Read/Read.ino @@ -1,4 +1,4 @@ -/* Sweep +/* Read by BARRAGAN This example code is in the public domain. From 879867bcf44d35ccb8c0ed4ca2dae89a4bd4c5ee Mon Sep 17 00:00:00 2001 From: S Jeeva <43230676+jeeva2812@users.noreply.github.com> Date: Thu, 19 Mar 2020 15:55:09 +0530 Subject: [PATCH 4/4] Update Read.ino --- examples/Read/Read.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/Read/Read.ino b/examples/Read/Read.ino index 3034836..d1e0ce9 100644 --- a/examples/Read/Read.ino +++ b/examples/Read/Read.ino @@ -2,6 +2,8 @@ by BARRAGAN This example code is in the public domain. + Example to sweep and display the angle in Serial Monitor + modified 18 Mar 2020 by S Jeeva */