File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -11,15 +11,21 @@ int main(void) {
11
11
return -1 ;
12
12
}
13
13
14
- uint16_t angle ;
14
+ uint16_t angle = 0 ;
15
15
16
16
// Changes the angle of the servomotor from 0 to 180 degrees (waiting 0.1 ms between every change).
17
17
for (int i = 0 ; i <= 180 ; i ++ ) {
18
- libtock_servo_angle (i );
19
- libtocksync_alarm_delay_ms (100 );
20
- // Verifies if the function successfully returned the current angle.
21
- if (libtock_current_servo_angle (& angle ) == RETURNCODE_SUCCESS ) {
22
- printf ("the current angle is: %d" , angle );
18
+ if (libtock_servo_angle (i ) == RETURNCODE_SUCCESS ) {
19
+ libtocksync_alarm_delay_ms (100 );
20
+ // Verifies if the function successfully returned the current angle.
21
+ if (libtock_current_servo_angle (& angle ) == RETURNCODE_SUCCESS ) {
22
+ printf ("The current angle is: %d\n" , angle );
23
+ } else {
24
+ printf ("\nThe servomotor is OFF\n" );
25
+ }
26
+ } else {
27
+ printf ("\nThe angle could not be changed\n" );
28
+ return -1 ;
23
29
}
24
30
}
25
31
}
You can’t perform that action at this time.
0 commit comments