PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Devices
Motor
Servo360
Set Angles 3 servos.c
1
/*
2
Set Angles.c
3
4
Turns to and holds positions.
5
Behaves like a standard RC servo when it reaches a given angle.
6
*/
7
8
#include "
simpletools.h
"
9
#include "
servo360.h
"
10
11
int
main
()
12
{
13
// Connect is required before control. The first argument is the I/O pin
14
// connected to the white control line, and the second is the I/O pin connected
15
// to the yellow feedback line.
16
int
s1 =
servo360_connect
(12, 14);
17
int
s2 =
servo360_connect
(13, 15);
18
int
s3
=
servo360_connect
(16, 6);
19
//int s3 = 0;
20
print
(
"s1 = %d, s2 = %d, s3 = %d\r"
, s1, s2,
s3
);
21
pause
(1000);
22
23
servo360_angle
(12, 0);
24
servo360_angle
(13, 0);
25
servo360_angle
(16, 0);
26
pause
(1000);
27
28
servo360_angle
(12, 45);
29
servo360_angle
(13, -45);
30
servo360_angle
(16, 45);
31
pause
(1500);
32
33
servo360_angle
(12, 360 + 45);
34
servo360_angle
(13, -360 -45);
35
servo360_angle
(16, 360 + 45);
36
pause
(2500);
37
38
servo360_angle
(12, 0);
39
servo360_angle
(13, 0);
40
servo360_angle
(16, 0);
41
pause
(1000);
42
}
servo360_angle
int servo360_angle(int pin, int position)
Set an angle in degrees for servo to move to and hold. The default degree is 1/360th of a full circle...
Definition:
servo360_angle.c:17
s3
Definition:
s3.h:63
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
servo360.h
Parallax Feedback 360 High Speed Servo control and monitoring functions. Uses one additional cog to c...
main
int main(void)
Definition:
GraphicsTest.c:20
servo360_connect
int servo360_connect(int pinControl, int pinFeedback)
Initializes a connection to a Parallax Feedback 360 servo. The current position of the servo during t...
Definition:
servo360_connect.c:19
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17