From 37fa0fbedc3e63742deea6f20e7a3b0efd230e33 Mon Sep 17 00:00:00 2001 From: inesmaria08 Date: Wed, 20 Nov 2024 19:38:52 +0200 Subject: [PATCH] adding readme --- examples/servo/README.md | 26 ++++++++++++++++++++++++++ examples/servo/main.c | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 examples/servo/README.md diff --git a/examples/servo/README.md b/examples/servo/README.md new file mode 100644 index 000000000..2fbb31d06 --- /dev/null +++ b/examples/servo/README.md @@ -0,0 +1,26 @@ +Servo Controller App +===================== + +A simple app that tests the functionality of a connected servo motor by reading its initial angle, adjusting the angle from 0 to 180 degrees, and verifying the actual angle at each step. + +Example Output +-------------- + +``` +The number of available servomotors is: 1 +Requested angle 0. Actual current angle is: 0 +Requested angle 1. Actual current angle is: 1 +Requested angle 2. Actual current angle is: 2 +... +Requested angle 180. Actual current angle is: 180 +``` + +If the servo index is out of range: +``` +The index number is bigger than the available servomotors +``` + +If the servo cannot report its angle: +``` +This servo cannot return its angle. +``` \ No newline at end of file diff --git a/examples/servo/main.c b/examples/servo/main.c index b84df593d..fa761d695 100644 --- a/examples/servo/main.c +++ b/examples/servo/main.c @@ -11,9 +11,9 @@ int main(void) { return -1; } returncode_t result = RETURNCODE_EOFF; - uint16_t servo_count = 0; + uint32_t servo_count = 0; libtock_servo_count(&servo_count); - printf("The number of available servomotors is: %d\n", servo_count); + printf("The number of available servomotors is: %ld\n", servo_count); uint16_t angle = 0; uint16_t index = 0; // the first index available.