-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharm_final.ino
76 lines (54 loc) · 1.35 KB
/
arm_final.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
67
68
69
70
71
72
73
74
75
76
/* Include the HCPCA9685 library */
#include "HCPCA9685.h"
/* I2C slave address for the device/module. For the HCMODU0097 the default I2C address
is 0x40 */
#define I2CAdd 0x40
#define shoulder 0
#define elbow 1
#define gripper 2
#define seeder 3
#define closed 100
#define opened 270
#define acopen 430
/* Create an instance of the library */
HCPCA9685 HCPCA9685(I2CAdd);
void setup()
{
/* Initialise the library and set it to 'servo mode' */
HCPCA9685.Init(SERVO_MODE);
/* Wake the device up */
HCPCA9685.Sleep(false);
HCPCA9685.Servo(shoulder, 200);
HCPCA9685.Servo(elbow, 250);
HCPCA9685.Servo(gripper, closed);
}
int mov(int servo,int start, int angle, float step_size){
for(int i=start; i < angle; i+= step_size){
HCPCA9685.Servo(servo, i);
delay(100);
}
}
int back(int servo, int start, int angle, float step_size){
for(int i=start; i > angle; i-= step_size){
HCPCA9685.Servo(servo,i);
delay(100);
}
}
void loop()
{
HCPCA9685.Servo(3, acopen);
delay(2000);
HCPCA9685.Servo(3, 0);
delay(3000);
mov (0,200, 400, 5);
back (1, 230, 50, 5);
HCPCA9685.Servo(gripper, opened);
back (0, 400, 150 ,5);
HCPCA9685.Servo(gripper, closed);
mov (0, 150, 400, 5);
mov (1, 50, 230,5);
HCPCA9685.Servo(gripper, opened);
delay(500);
HCPCA9685.Servo(gripper, closed);
delay(5000);
}