[{"element_type":"image_url","content":"https://img.youtube.com/vi/KSmhdnoUq08/maxresdefault.jpg","metadata":{"alt":"YouTube Thumbnail","caption":""}},{"element_type":"text","content":"\n  \n  \n        \u003cp class=\"elements_paragraph__08_3b\" style=\"text-align: left;\"\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003e\u003cstrong\u003eVarSpeedServoRA4M1\u003c/strong\u003e is a library for Arduino tha enables precise \u003cstrong\u003econtrol\u003c/strong\u003e over \u003cstrong\u003eservo motors\u003c/strong\u003e, including \u003cstrong\u003espeed\u003c/strong\u003e, \u003cstrong\u003eposition\u003c/strong\u003e, and \u003cstrong\u003emovement sequences\u003c/strong\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cp class=\"elements_paragraph__08_3b\" style=\"text-align: left;\"\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eDeveloped by \u003cstrong\u003eKaled Souky\u003c/strong\u003e in 2024, based on the \u003cstrong\u003eServo\u003c/strong\u003e library (developed by \u003cstrong\u003eMichael Margolis\u003c/strong\u003e in 2009) and \u003cstrong\u003eVarSpeedServo\u003c/strong\u003e library (developed by \u003cstrong\u003eKorman\u003c/strong\u003e in 2010 and updated by \u003cstrong\u003ePhilip van Allen\u003c/strong\u003e in 2013). Specifically designed for the \u003cstrong\u003eRenesas RA4M1\u003c/strong\u003e microcontroller architecture (\u003cstrong\u003eArm Cortex-M4\u003c/strong\u003e), present on the \u003cstrong\u003eArduino UNO R4 Minima\u003c/strong\u003e and \u003cstrong\u003eArduino UNO R4 WiFi\u003c/strong\u003e boards.\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cp class=\"elements_paragraph__08_3b\" style=\"text-align: left;\"\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003e\u003cstrong\u003eVarSpeedServoRA4M1\u003c/strong\u003e is an interrupt-driven library using 16-bit timers, allowing the use of \u003cstrong\u003eup to 12 servos\u003c/strong\u003e \u003cstrong\u003emoving asynchronously or synchronously\u003c/strong\u003e. In addition to \u003cstrong\u003esetting\u003c/strong\u003e \u003cstrong\u003ethe\u003c/strong\u003e \u003cstrong\u003eposition\u003c/strong\u003e, you can \u003cstrong\u003eset\u003c/strong\u003e \u003cstrong\u003ethe\u003c/strong\u003e \u003cstrong\u003espeed\u003c/strong\u003e of a movement, optionally \u003cstrong\u003ewait until the servo movement is completed\u003c/strong\u003e, and \u003cstrong\u003ecreate sequences of movements\u003c/strong\u003e that execute asynchronously or synchronously. \u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cp class=\"elements_paragraph__08_3b\" style=\"text-align: left;\"\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eThe \u003cstrong\u003e32-bit Renesas RA4M1\u003c/strong\u003e processor operating at \u003cstrong\u003e48 MHz\u003c/strong\u003e elevates servo control to a new level, providing \u003cstrong\u003ehigher\u003c/strong\u003e \u003cstrong\u003ePWM\u003c/strong\u003e \u003cstrong\u003eresolution\u003c/strong\u003e compared to the \u003cstrong\u003eATmega328P\u003c/strong\u003e used in \u003cstrong\u003eArduino UNO R3\u003c/strong\u003e. Thanks to this power, \u003cstrong\u003eVarSpeedServoRA4M1\u003c/strong\u003e fully exploits the microcontroller's capabilities. With its \u003cstrong\u003esimple and intuitive syntax\u003c/strong\u003e, this library facilitates precise control over servo position and speed, even for beginners. Creating complex movement sequences is straightforward with just a few commands.\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cp class=\"elements_paragraph__08_3b\" style=\"text-align: left;\"\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp style=\"text-align: left;\"\u003e\u003cstrong\u003e\u003cspan style=\"text-decoration: underline;\"\u003eFeatures :\u003c/span\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cul style=\"text-align: left;\"\u003e\n\u003cli\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eSupports up to\u0026nbsp;\u003cstrong\u003e12\u003c/strong\u003e servos. \u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\n\u003cli\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eAllows \u003cstrong\u003esynchronous\u003c/strong\u003e and \u003cstrong\u003easynchronous\u003c/strong\u003e movement of\u0026nbsp; all servos. \u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\n\u003cli\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eAllows you to configure the \u003cstrong\u003e\"position\"\u003c/strong\u003e and \"\u003cstrong\u003espeed\u003c/strong\u003e\" of each servo individually. \u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\n\u003cli\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eIncludes a \u003cstrong\u003e\"wait\"\u003c/strong\u003e parameter to wait for the servo to complete its movement. \u003cstrong\u003ePhilip van Allen\u003c/strong\u003e, in his update, incorporated it as a boolean variable within the \u003ccode\u003ewrite()\u003c/code\u003e function, and also as the independent \u003ccode\u003ewait()\u003c/code\u003e function. This parameter is not included as a variable in \u003cstrong\u003eKorman's\u003c/strong\u003e \u003ccode\u003eslowmove()\u003c/code\u003e function. \u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\n\u003cli\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eThe \u003ccode\u003ewrite()\u003c/code\u003e function now includes the \u003cstrong\u003e\"speed\"\u003c/strong\u003e and \u003cstrong\u003e\"wait\"\u003c/strong\u003e parameters, which can optionally be used in conjunction with the \"\u003cstrong\u003eposition\u003c/strong\u003e\" parameter to control servo movement. \u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\n\u003cli\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eThe \u003ccode\u003eslowmove()\u003c/code\u003e function is retained for \u003cstrong\u003ecompatibility\u003c/strong\u003e with the \u003cstrong\u003eKorman\u003c/strong\u003e version. It only handles the \u003cstrong\u003e\"position\"\u003c/strong\u003e and \u003cstrong\u003e\"speed\"\u003c/strong\u003e parameters. In this case, the waiting time must be configured (using, for example, the function \u003ccode\u003edelay()\u003c/code\u003e, \u003ccode\u003edelayMicroseconds()\u003c/code\u003e, \u003ccode\u003emicros()\u003c/code\u003e or \u003ccode\u003emillis()\u003c/code\u003e), so that the servo completes the position and maintains it for the desired time. The \u003ccode\u003eslowmove()\u003c/code\u003e function does not incorporate the \u003cstrong\u003e\"wait\"\u003c/strong\u003e variable introduced by \u003cstrong\u003ePhilip van Allen\u003c/strong\u003e in the \u003ccode\u003ewrite()\u003c/code\u003e function. \u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\n\u003cli\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eAllows the creation of position \u003cstrong\u003esequences\u003c/strong\u003e.\u0026nbsp;\u003cbr\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp class=\"elements_paragraph__08_3b\" style=\"text-align: left;\"\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp class=\"elements_paragraph__08_3b\" style=\"text-align: left;\"\u003e\u003cspan style=\"text-decoration: underline;\"\u003e\u003cstrong\u003eExamples of use:\u0026nbsp;\u003c/strong\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cp class=\"elements_paragraph__08_3b\" style=\"text-align: left;\"\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003e\u003cstrong\u003eSample code 1:\u003c/strong\u003e\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eSweeps a servo motor from \u003cstrong\u003e0\u003c/strong\u003e to \u003cstrong\u003e180\u003c/strong\u003e degrees at fast speed and back from \u003cstrong\u003e18\u003c/strong\u003e0 to \u003cstrong\u003e0\u003c/strong\u003e degrees at slow speed, in an infinite loop. \u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cp class=\"elements_paragraph__08_3b\" style=\"text-align: left;\"\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eThe \u003ccode\u003ewrite()\u003c/code\u003e function now includes the \u003cstrong\u003e\"speed\"\u003c/strong\u003e and \u003cstrong\u003e\"wait\"\u003c/strong\u003e parameters, which can optionally be used in conjunction with the \u003cstrong\u003e\"position\"\u003c/strong\u003e parameter to control servo movement. \u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cp class=\"elements_paragraph__08_3b\" style=\"text-align: left;\"\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eThe \u003cstrong\u003e\"wait\"\u003c/strong\u003e parameter is used to wait for the servo to complete its movement. It is also available as a standalone \u003ccode\u003ewait()\u003c/code\u003e function.\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\n      \n\n","metadata":{}},{"element_type":"code","content":"#include \u003cVarSpeedServoRA4M1.h\u003e \n \nVarSpeedServoRA4M1 myservo;  // create servo object to control a servo \n// A maximum of twelve servo objects can be created\n\nconst int servoPin = 9;  // the digital pin used for the servo\n\nvoid setup() { \n  myservo.attach(servoPin);  // attaches the servo on pin 9 to the servo object\n  myservo.write(0,127,true);  // set the servo to its initial position at fast speed, wait for completion\n} \n\nvoid loop() {\n  // write(degrees 0-180, speed 1-255, wait to complete true-false)\n  /* On the RC servos tested, speed differences above 127 \n     cannot be noticed due to the mechanical limitations of \n     the servo. However, feel free to experiment with the \n     speed value that best suits the response of your servo \n     based on its mechanical and electronic characteristics \n  */\n  myservo.write(180,127,true);  // move the servo to 180, fast speed, wait until done\n  myservo.write(0,30,true);  // move the servo to 0, slow speed, wait until done\n}","metadata":{"language":"cpp","linenums":false}},{"element_type":"text","content":"\n  \n        \u003cp class=\"elements_paragraph__08_3b\"\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003e\u003cstrong\u003eSample code 2:\u003c/strong\u003e \u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eSweeps a servo motor from \u003cstrong\u003e0\u003c/strong\u003e to \u003cstrong\u003e180\u003c/strong\u003e degrees at fast speed and back from \u003cstrong\u003e180\u003c/strong\u003e to \u003cstrong\u003e0\u003c/strong\u003e degrees at slow speed, in an infinite loop. \u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cp class=\"elements_paragraph__08_3b\"\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eThe \u003ccode\u003eslowmove()\u003c/code\u003e function only handles the \u003cstrong\u003e\"position\"\u003c/strong\u003e and \u003cstrong\u003e\"speed\"\u003c/strong\u003e parameters. In this case, the wait time must be set (using, for example, the \u003ccode\u003edelay()\u003c/code\u003e, \u003ccode\u003emillis()\u003c/code\u003e, \u003ccode\u003emicros()\u003c/code\u003e, or \u003ccode\u003edelayMicroseconds()\u003c/code\u003e functions) to ensure the servo completes the position and maintains it for the desired time. The \u003ccode\u003eslowmove()\u003c/code\u003e function does not incorporate the \u003cstrong\u003e\"wait\"\u003c/strong\u003e variable. \u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cp class=\"elements_paragraph__08_3b\"\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eThis example demonstrates the use of the \u003ccode\u003edelay()\u003c/code\u003e function as a timeout with \u003ccode\u003eslowmove()\u003c/code\u003e. The exact delay value may require some experimentation (usually in the millisecond range) to ensure that the servo has enough time to reach its target position and hold it for as long as necessary, until receiving the next instruction.\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\n      \n","metadata":{}},{"element_type":"code","content":"#include \u003cVarSpeedServoRA4M1.h\u003e \n \nVarSpeedServoRA4M1 myservo;  // create servo object to control a servo \n// A maximum of twelve servo objects can be created \n \nconst int servoPin = 9;  // the digital pin used for the servo\n \nvoid setup() { \n  myservo.attach(servoPin);  // attaches the servo on pin 9 to the servo object\n  myservo.slowmove(0,127);  // set the servo to its initial position at fast speed\n  delay(1000);  // sets the time the servo needs to reach the position and stay there\n} \n\nvoid loop() {\n  // slowmove(degrees 0-180, speed 1-255)\n  /* On the RC servos tested, speed differences above 127 \n     cannot be noticed due to the mechanical limitations of \n     the servo. However, feel free to experiment with the \n     speed value that best suits the response of your servo \n     based on its mechanical and electronic characteristics \n  */\n  myservo.slowmove(180,127);  // move the servo to 180, fast speed\n  delay(1000);  // sets the time the servo needs to reach the position and stay there\n  myservo.slowmove(0,30);  // move the servo to 0, slow speed\n  delay(3700);  // sets the time the servo needs to reach the position and stay there\n}","metadata":{"language":"cpp","linenums":false}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003cp\u003e\u003cspan style=\"text-decoration: underline;\"\u003e\u003cstrong\u003e\u003cspan\u003eConnection diagram: \u003c/span\u003e\u003c/strong\u003e\u003c/span\u003e\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"image_url","content":"https://docs.arduino.cc/static/9521df5ddacc221dd7560ba80e2acc3e/a6d36/servo_circuit_knob.png","metadata":{"alt":"https://docs.arduino.cc/static/9521df5ddacc221dd7560ba80e2acc3e/a6d36/servo_circuit_knob.png","caption":""}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003cp class=\"elements_paragraph__08_3b\"\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003eImage taken from the official Arduino website:\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003e\u003ca href=\"https://docs.arduino.cc/learn/electronics/servo-motors/\"\u003ehttps://docs.arduino.cc/learn/electronics/servo-motors/\u003c/a\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cp class=\"elements_paragraph__08_3b\"\u003e\u0026nbsp;\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"alert","content":"\u003cp\u003eExternal devices with a high current draw (e.g. servo motors) should never be powered via the 5 V pin. It is mainly intended for devices drawing lower current such as sensor modules\u003c/p\u003e","metadata":{"class":"element alert-element build-alert alert-danger","markdown":"External devices with a high current draw (e.g. servo motors) should never be powered via the 5 V pin. It is mainly intended for devices drawing lower current such as sensor modules","alert_type":"danger"}},{"element_type":"alert","content":"\u003cp\u003eAdditional examples are included in the VarSpeedServoRA4M1.h library. Once installed, they are available in the Examples section of the Arduino IDE\u003c/p\u003e","metadata":{"class":"element alert-element build-alert alert-info","markdown":"Additional examples are included in the VarSpeedServoRA4M1.h library. Once installed, they are available in the Examples section of the Arduino IDE","alert_type":"info"}},{"element_type":"embed","content":"https://www.youtube.com/watch?v=KSmhdnoUq08"},{"element_type":"text","content":"\n        \u003cp\u003e\u003cspan\u003e\u003cstrong\u003eLike\u003c/strong\u003e this \u003cstrong\u003evideo\u003c/strong\u003e, \u003cstrong\u003esubscribe\u003c/strong\u003e, \u003cstrong\u003eshare\u003c/strong\u003e, and if you can, \u003cstrong\u003ebuy me a Ko-fi\u003c/strong\u003e:\u0026nbsp;\u003c/span\u003e\u003cspan\u003e\u003ca href=\"https://ko-fi.com/kaledsouky\"\u003ehttps://ko-fi.com/kaledsouky\u003c/a\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cp\u003e\u003cspan\u003e\u003cstrong\u003eThanks\u003c/strong\u003e for being part of this \u003cstrong\u003eamazing community! Together, we can create amazing things!\u003c/strong\u003e\u0026nbsp;\u003c/span\u003e\u003c/p\u003e\n      ","metadata":{}},{"element_type":"alert","content":"\u003cp\u003eVarSpeedServoRA4M1 Library GitHub repository:\u003c/p\u003e\n\n\u003cp\u003e\u003ca href=\"https://github.com/KaledSouky/VarSpeedServoRA4M1\"\u003ehttps://github.com/KaledSouky/VarSpeedServoRA4M1\u003c/a\u003e\u003c/p\u003e\n\n\u003cp\u003eLearn how to install additional libraries in the Arduino IDE:\u003c/p\u003e\n\n\u003cp\u003e\u003ca href=\"https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries/\"\u003ehttps://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries/\u003c/a\u003e\u003c/p\u003e\n\n\u003cp\u003eLearn how to connect and control servo motors with your Arduino board:\u003c/p\u003e\n\n\u003cp\u003e\u003ca href=\"https://docs.arduino.cc/learn/electronics/servo-motors/\"\u003ehttps://docs.arduino.cc/learn/electronics/servo-motors/\u003c/a\u003e\u003c/p\u003e","metadata":{"class":"element alert-element build-alert alert-info","markdown":"VarSpeedServoRA4M1 Library GitHub repository:\n\nhttps://github.com/KaledSouky/VarSpeedServoRA4M1\n\nLearn how to install additional libraries in the Arduino IDE:\n\nhttps://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries/\n\nLearn how to connect and control servo motors with your Arduino board:\n\nhttps://docs.arduino.cc/learn/electronics/servo-motors/","alert_type":"info"}}]