 long btnUpTime; // time the button was released
 boolean ignoreUp = false; // whether to ignore the button release because the click+hold was triggered
 boolean ledVal1 = false; // state of LED 1
-int AnalogDataPin = A1; // this may be changed depending on circuit wiring
+int AnalogDataPin = A0; // this may be changed depending on circuit wiring
 int Count;
 float Voltage;
 float SensorReading;

  Serial.println(Units);
  StartTime = millis();// time of last reading in ms
  for (Sample=0;Sample<NumberOfPoints;Sample++)
  {digitalWrite(ledPin1, true);
    Serial.print(Sample);
    Serial.print("\t");
    //the print below does the division first to avoid overflows
    Serial.print(Sample/1000.0*TimeBetweenReadings); 
    Serial.print("\t");
    Count= analogRead(A1);
    Voltage = Count * (5.0/ 1024);
    SensorReading = Intercept + Voltage * Slope;
    Serial.println(SensorReading);
    EEPROM.write(addr, lowByte(Count));
    EEPROM.write(addr + 1, highByte(Count));
    addr +=2;  //increment address pointer twice 
   delay (TimeBetweenReadings/2);//these lines are to give a blink to the LED
   digitalWrite(ledPin1, false);
   delay (TimeBetweenReadings/2);
  }
//the number of points is stored at base and base+1;
//data starts at the next two bytes (base=2 and base+3, etc);
EEPROM.write(base+ 0, lowByte(NumberOfPoints));
EEPROM.write(base + 1, highByte(NumberOfPoints));
Serial.println(" ");
Serial.println("Press button briefly to send data to Serial Monitor");
Serial.println("Press and hold to collect new data");
Serial.println(" ");
digitalWrite(ledPin1, false);
};//end of Data Collect


///////////////////////////////////
void setup()
{
  // Set button input pin
  pinMode(buttonPin, INPUT);
  digitalWrite(buttonPin, HIGH);
  pinMode(AnalogDataPin, INPUT);
  pinMode(ledPin1, OUTPUT);// Set LED output pin
  Serial.begin(9600);
  Serial.println("VernierAnalogStore sketch");
  Serial.println("Press and hold to collect new data");
  Serial.println("Press button briefly to read data stored in EEPROM");
  Serial.println("and send it to the Serial Monitor");
  Serial.println(" ");
}
void loop()
{
  digitalWrite(ledPin1, false);
  // Read the state of the button
  buttonVal = digitalRead(buttonPin);// button down is low
  // Test for button pressed and store the down time
  if (buttonVal == LOW && buttonLast == HIGH && (millis() - btnUpTime) > long(debounce))
    { 
      //button pressed
       btnDnTime = millis();// note time of press
     }
  // Test for button release and store the up time
  if (buttonVal == HIGH && buttonLast == LOW && (millis() - btnDnTime) > long(debounce))
    {
       if (ignoreUp == false) ReadEEPROMData();// read data from EEPROM and send to Serial Monitor
       else ignoreUp = false;
       btnUpTime = millis();// note time of button release
     }
  // Test for button held down for longer than the hold time
  if (buttonVal == LOW && (millis() - btnDnTime) > long(holdTime))
    {
      CollectData(); //collect new data
      ignoreUp = true;
      btnDnTime = millis(); // get new button down time
    }
  buttonLast = buttonVal;
}
//=================================================
// Events to trigger by click and press+hold
