pcom_week8 mid_final and presentation

CODE:
// SERVO MOTOR PINS int servoArray[]= {10,11,12,13};////Array for pins connected to the sevos
int minPulse = 500; // Minimum servo position int maxPulse = 2500; // Maximum servo position int pulse = 0; // Amount to pulse the servo long lastPulse = 0; int refreshTime = 20;
int analogValue = 0; //Var for inputs. We are using just one value for the 4 sevos.
int micVar=0; //Var for the input of the mic int AmpVar=0;
// ANALOG-IN PIN int analogPin = 0; int pinArray[]= {2,3,4,5,6,7,8,9}; //Array for pins connected to the LEDs int waitNextLed= 100; // Time between LEDs int tailLength = 8; //LEDs tail stay lit int lineSize= 8; //Number of lines of LEDs
//VAR FOR COUNTERS int i; int j; int k; int h; int l; int m; int n;
void setup() {
Serial.begin(9600); pinMode(analogPin,INPUT);
for (k=0; k< 4; k++){ pinMode(servoArray[k],OUTPUT); }
for (int j=0; j
pulse = minPulse; // Set the motor position value to the minimum
}
void loop() { //Amp Mic
micVar= analogRead(analogPin); if(micVar>=512){ AmpVar= micVar-512; } else{ AmpVar=512-micVar; } analogValue = AmpVar; // read the analog input Serial.println(AmpVar); // SERVO MOTOR pulse= ((analogValue-150)*(2000/200)+minPulse); if (millis() - lastPulse >= refreshTime) { for(h=0; h< 4; h++){ digitalWrite(servoArray[h], HIGH); // Turn the motor on delayMicroseconds(pulse); // Length of the pulse sets the motor position digitalWrite(servoArray[h], LOW); // Turn the motor off } lastPulse = millis(); // save the time of the last pulse
}
// LED's
if (analogValue <200) { lineSize=8; for(l=0; l
else { if (analogValue >201 && analogValue< 280) {
lineSize=4;
} if (analogValue >281 && analogValue< 350) {
lineSize=6;
}
if (analogValue >351) {
lineSize=8;
}
int tailCounter=tailLength; for(m=0; m
tailCounter--; } for(n=(lineSize-tailLength); n
}
}

