Browse Source

optimization

develop
Carmine De Rosa 6 years ago
parent
commit
7a1eb8975a
  1. 48
      arduino/arduino.ino

48
arduino/arduino.ino

@ -5,6 +5,8 @@ Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
#define SERVOMIN 330 // this is the 'minimum' pulse length count (out of 4096) - increasing SERVOMIN decrease speed #define SERVOMIN 330 // this is the 'minimum' pulse length count (out of 4096) - increasing SERVOMIN decrease speed
#define SERVOMAX 390 // this is the 'maximum' pulse length count (out of 4096) #define SERVOMAX 390 // this is the 'maximum' pulse length count (out of 4096)
#define TIMER 200
#define SERVODIVIDER 5
const char HEADER = 'H'; const char HEADER = 'H';
const char A_TAG = 'M'; const char A_TAG = 'M';
@ -64,32 +66,32 @@ void loop() {
} }
} }
while(cycle < 8) {
for(int i=0; i<8; i++) { for(int i=0; i<8; i++) {
Serial.print(values[i]);
Serial.print(" ");
if(values[i]>0) {
values[i]--;
digitalWrite(atomPins[i], HIGH);
//pwm.setPWM(i, 0, SERVOMIN);
if(values[i]==0) {
cycle++;
digitalWrite(atomPins[i], LOW);
//pwm.setPWM(i, 0, ((SERVOMAX-SERVOMIN)/2)+SERVOMIN);
}
} else {
//cycle++;
//digitalWrite(atomPins[i], LOW);
}
}
Serial.println("");
delay(500);
pwm.setPWM(i, 0, SERVOMIN);
delay(values[i]*SERVODIVIDER);
pwm.setPWM(i, 0, ((SERVOMAX-SERVOMIN)/2)+SERVOMIN);
}
//digitalWrite(13, LOW);
while(cycle < 8) {
for(int i=0; i<8; i++) {
Serial.print(values[i]);
Serial.print(" ");
if(values[i]>0) {
values[i]--;
digitalWrite(atomPins[i], HIGH);
if(values[i]==0) {
cycle++;
digitalWrite(atomPins[i], LOW);
}
}
}
Serial.println("");
delay(TIMER);
//digitalWrite(13, LOW);
}
} }
} }
}
} }

Loading…
Cancel
Save