-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sterowanie_Servo.h~RF2a7ea9.TMP
47 lines (40 loc) · 1.71 KB
/
Sterowanie_Servo.h~RF2a7ea9.TMP
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
#pragma once
// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
// you can also call it with a different address and I2C interface
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40, Wire);
// Depending on your servo make, the pulse width min and max may vary, you
// want these to be as small/large as possible without hitting the hard stop
// for max range. You'll have to tweak them as necessary to match the servos you
// have!
#define SERVOMIN 150 // This is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX 600 // This is the 'maximum' pulse length count (out of 4096)
#define USMIN 600 // This is the rounded 'minimum' microsecond length based on the minimum pulse of 150
#define USMAX 2400 // This is the rounded 'maximum' microsecond length based on the maximum pulse of 600
#define SERVO_FREQ 50 // Analog servos run at ~50 Hz updates
// our servo # counter
uint8_t servonum = 0;
uint16_t pulselen = 250;
void moveServo(uint8_t servonum) {
Serial.println("serwo");
Serial.println(servonum);
Serial.println("serwo1");
uint16_t pulselen = 250; //dlugosc impulsu
for (pulselen = 250; pulselen < 500; pulselen++) {
pwm.setPWM(servonum, 0, pulselen);
delay(10);
Serial.println("serwo10");
Serial.println(pulselen);
}
delay(100);
for (pulselen = 500; pulselen > 250; pulselen--) {
pwm.setPWM(servonum, 0, pulselen);
delay(10);
Serial.println("serwo11");
Serial.println(pulselen);
}
Serial.println("serwo2");
return;
}