int analogPin = 3; int data = 0; char userInput; void setup() { // put your setup code here, to run once: pinMode(LED_BUILTIN, OUTPUT); Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: if(Serial.available()>0) { userInput = Serial.read(); if(userInput == 'g') { data = analogRead(analogPin); /* digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(200); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(200); digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(200); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(200); digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(200); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(200); */ delay(2000); Serial.println(data); } } }