-
Notifications
You must be signed in to change notification settings - Fork 0
/
Servo.ino
66 lines (59 loc) · 1.13 KB
/
Servo.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
Author:
Matt Tucker
Date:
22MAY2018
Description:
The following test is to for the servo motor.
It will turn the servo to several points and
then return it to the 90deg post.
Note:
write() "measurement" to degrees->
2000 = 180*
1500 = 90*
1000 = 0*
*/
//***Servo***
//#include <Servo.h>
//Servo servo1;
//const int servoPin = 9;
#include <ServoTimer2.h>
#define servoPin 9
ServoTimer2 servo1;
//********END*****//
//***GeneralGlobalVariables***
#include <math.h>
int rndNum;
int count = 0;
//********END*****//
void setup()
{
//***Servo***
servo1.attach(servoPin);
//********END*****//
}
//***Servo***
//Turn() moves the servo to the 180 post to to 90, then to 0,
//and back to 90
void Servo_Motor_Turn()
{
servo1.write(2000);
delay(1000);
servo1.write(1500);
delay(1000);
servo1.write(1000);
delay(1000);
servo1.write(1500);
delay(1000);
}
//UnTurn() centers the servo
void Servo_Motor_UnTurn()
{
servo1.write(1500);
}
//********END*****//
void loop()
{
Servo_Motor_UnTurn();
Servo_Motor_Turn();
}