@@ -23,20 +23,17 @@ void setup() {
23
23
Serial.begin (115200 );
24
24
Serial.println (" I2CDevLib Example - PCA9685 Test" );
25
25
26
- if (!Wire.begin ()) {
27
- Serial.println (" [E] Failed to init Wire!" );
28
- while (true ) {};
29
- }
26
+ Wire.begin ();
30
27
31
28
// auto result = pca9685.setPrescale(100);
32
29
result = pca9685.setFrequency (SERVO_FREQ);
33
30
if (result != I2CDEV_RESULT_OK) {
34
- Serial.printf (" [E] Failed to set PCA9685 prescale: %i \n " , result );
31
+ Serial.println (" [E] Failed to set PCA9685 prescale" );
35
32
while (true ) {};
36
33
}
37
34
result = pca9685.wakeup ();
38
35
if (result != I2CDEV_RESULT_OK) {
39
- Serial.printf (" [E] Failed wakeup PCA9685: %i \n " , result );
36
+ Serial.println (" [E] Failed to wake up PCA9685 " );
40
37
while (true ) {};
41
38
}
42
39
@@ -46,16 +43,14 @@ void setup() {
46
43
uint8_t currentServo = 0 ;
47
44
48
45
void loop () {
49
- Serial.printf (" Current servo: %i \n " , currentServo);
46
+ Serial.print (" Current servo: " ); Serial. println ( currentServo);
50
47
51
48
Serial.println (" \t > SERVO_PULSE_LEN_MIN => SERVO_PULSE_LEN_MAX" );
52
49
for (uint16_t pulseLen = SERVO_PULSE_LEN_MIN; pulseLen < SERVO_PULSE_LEN_MAX; pulseLen++) {
53
50
result = pca9685.setChannel (currentServo, pulseLen);
54
51
if (result != I2CDEV_RESULT_OK) {
55
- Serial.printf (" [E] Failed to set PCA9685 pin: %i \n " , result );
52
+ Serial.println (" [E] Failed to set PCA9685 pin" );
56
53
}
57
- // delay(5);
58
- // Serial.printf("\t > SERVO_PULSE_LEN_MIN => SERVO_PULSE_LEN_MAX: %i\n", pulseLen);
59
54
}
60
55
61
56
delay (500 );
@@ -64,10 +59,8 @@ void loop() {
64
59
for (uint16_t pulseLen = SERVO_PULSE_LEN_MAX; pulseLen > SERVO_PULSE_LEN_MIN; pulseLen--) {
65
60
result = pca9685.setChannel (currentServo, pulseLen);
66
61
if (result != I2CDEV_RESULT_OK) {
67
- Serial.printf (" [E] Failed to set PCA9685 pin: %i \n " , result );
62
+ Serial.println (" [E] Failed to set PCA9685 pin" );
68
63
}
69
- // delay(5);
70
- // Serial.printf("\t > SERVO_PULSE_LEN_MAX => SERVO_PULSE_LEN_MIN: %i\n", pulseLen);
71
64
}
72
65
73
66
delay (500 );
@@ -76,10 +69,8 @@ void loop() {
76
69
for (uint16_t uSec = SERVO_US_MIN; uSec < SERVO_US_MAX; uSec++) {
77
70
result = pca9685.writeMicroseconds (currentServo, uSec);
78
71
if (result != I2CDEV_RESULT_OK) {
79
- Serial.printf (" [E] Failed to set PCA9685 microseconds: %i \n " , result );
72
+ Serial.println (" [E] Failed to set PCA9685 microseconds" );
80
73
}
81
- // delay(5);
82
- // Serial.printf("\t > SERVO_US_MIN => SERVO_US_MAX: %i\n", uSec);
83
74
}
84
75
85
76
delay (500 );
@@ -88,10 +79,8 @@ void loop() {
88
79
for (uint16_t uSec = SERVO_US_MAX; uSec > SERVO_US_MIN; uSec--) {
89
80
result = pca9685.writeMicroseconds (currentServo, uSec);
90
81
if (result != I2CDEV_RESULT_OK) {
91
- Serial.printf (" [E] Failed to set PCA9685 microseconds: %i \n " , result );
82
+ Serial.println (" [E] Failed to set PCA9685 microseconds" );
92
83
}
93
- // delay(5);
94
- // Serial.printf("\t > SERVO_US_MAX => SERVO_US_MIN: %i\n", uSec);
95
84
}
96
85
97
86
delay (500 );
0 commit comments