« pcom_week7 replacement Mic. | Main | pcom_week11 Final Prototype "alpha" »

pcom_week8 mid_final and presentation

mid_final.gif


This is the picture of my Mid_final project, Soundelier. Below is the code for the ServoMotor.




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; m0){
tailCounter--;
} 
for(n=(lineSize-tailLength); n }
}


}


final.jpg


Here's the almost finished project.



below is the finished project "Soundelier"



final02.gif

TrackBack

TrackBack URL for this entry:
http://itp.nyu.edu/~yp364/cgi-bin/mt/mt-tb.cgi/45

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)