// Declare the Analog pin on the Arduino board
int buttonPin = A0;
void setup() {
// Establish the Serial connection with a baud rate of 9600
Serial.begin(9600);
}
void loop(){
// Read the value of the input. It can vary from 0 - 1023
int buttonValue = analogRead(buttonPin);
if (buttonValue < 90){
// A value under 90 represents no button pushed
Serial.print("No Value = ");
} else if (buttonValue >= 200 && buttonValue < 300){
// A value between 200 - 300 represents the third button
Serial.print("S3 = ");
} else if (buttonValue >= 400 && buttonValue < 550){
// A value between 400 - 550 represents the second button
Serial.print("S2 = ");
} else if (buttonValue >= 650){
// A value greater than 650 represents the first button
Serial.print("S1 = ");
}
Serial.println(analogRead(A0));
delay(10);
// Delays the execution to allow time for the Serial transmission
delay(300);
}
//Puente, Ma. Jessica P. TCPE 4-1 Prelim