Humirel HS1101 Help

Nothing I've found really works well, so I started from scratch.

/*
Wiring Instructions: Sensor ground to ground.  Digital pin 13 to 10k ohm resistor to sensor input (series).  Sensor input to 220 ohm resistor to digital pin 11 (series).  Analog pin 0 to sesnsor input.
Future enhancements: 1) Find a way to more fully charge before discharging.  2) take average of several readings before displaying value as in previous code.  3) tweak the relHum calculation.
*/
int analogPin = 0;
int chargePin = 13;
int dischargePin = 11;
unsigned long startTime;
unsigned long elapsedTime;
float relHum;                

void setup(){
  pinMode(chargePin, OUTPUT);     
  digitalWrite(chargePin, LOW);  
  Serial.begin(9600);             
}

void loop(){
  digitalWrite(chargePin, HIGH);  // charge capacitor
  while(analogRead(analogPin) < 300){ 
  //A full 5V should be a value of 1023, but I can only get it to vary from 330-365
  }
  digitalWrite(chargePin, LOW);             // turn off charge pin 
  startTime = micros();
  pinMode(dischargePin, OUTPUT);            // set discharge pin to output 
  digitalWrite(dischargePin, LOW);          // discharge capacitor 
  while(analogRead(analogPin) > 0){         // wait until capacitor is fully discharged
  }
  elapsedTime = micros() - startTime;       // calculate decay time
  relHum = ((elapsedTime * 0.2143) + 9.43); //simple algebra from a few known values with another humidity meter
  Serial.println(relHum);                   // print the value to serial monitor
  pinMode(dischargePin, INPUT);             // reset discharge pin
  delay(1000);                              // let it settle
}

I wouldn't rely on this, but it's in the ballpark, giving values within 5% or so of my Radio Shack humidity meter. It's a little slow to react sometimes and tends to randomly bounce around a bit though.