Arduino Balloon Blow up Code

Version 02 of balloon code, works well, the interval timing for the output to the valve is now set so that it pulses at equal intervals over the period given between messages from the twitter app which is 5 seconds. This can be changed along with the time for the squirt of air

/** Balloon blow up v02, 12.15 08/01/2009, Pete Rogers **/ char serString[4]; int ledPin = 13; int valvePin = 7; int serInt; int pulseDelay; int squirtDelay = 250; //change to shorten - lengthen the squirt time int loopDelay = 5000; //change to match the delay timing of the twitter App void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); pinMode(valvePin, OUTPUT); } void loop() { delay(100); readSerial(serString); serInt = atoi(serString); if (serInt > 0){ pulseDelay = loopDelay / (serInt + 1); pulseDelay = pulseDelay - (squirtDelay / 2); Serial.println(pulseDelay); if ( pulseDelay < 0){ digitalWrite(ledPin, HIGH); digitalWrite(valvePin, HIGH); delay(loopDelay); digitalWrite(ledPin, LOW); digitalWrite(valvePin, LOW); clearSerial(); }else{ for(int i = 0; i < serInt; i++){ digitalWrite(ledPin, HIGH); digitalWrite(valvePin, HIGH); delay(squirtDelay); digitalWrite(ledPin, LOW); digitalWrite(valvePin, LOW); delay(pulseDelay); clearSerial(); } } } delay(50); } void readSerial(char *strArray) { int i = 0; if(!Serial.available()) { return; } while (Serial.available()) { strArray[i] = Serial.read(); i++; } } void clearSerial() { for (int i=0; i < 4; i++) { serString[i] = ' '; } }