// output analog data only when requested
// From: wiki.seeedstudio.com/Grove-Beginner-Kit-For-Arduino/

int  analogPin = A0;
int  data = 0;
char userInput;

void setup() {
  Serial.begin(9600);
}

void loop() {

  if (Serial.available() > 0) {
 
    userInput = Serial.read();       // read users input

    if (userInput == 'g') {          // if we get the expected value
      data = analogRead(analogPin);  // read the input pin
      delay(10);                     // pause "just because"
      Serial.println(data); 
    }

  }
}
