const int potPin = A1; // Analog input pin for the potentiometer
const int buttonPin = 2;
int potValue = 0; // Variable to store the potentiometer value
int lastPotValue=0;
int buttonState = 0;
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud
}
void loop() {
// Read the analog value from the potentiometer
lastPotValue = potValue;
int newPotValue = map(analogRead(potPin), 0, 1023, 0, 127);
if(newPotValue != lastPotValue){
// Changed
potValue = newPotValue;
// Print the potentiometer value to the serial monitor
Serial.print("Potentiometer Value: ");
Serial.println(potValue);
}
int newButtonState = digitalRead(buttonPin);
if(newButtonState != buttonState){
// Button state change
buttonState = newButtonState;
Serial.print("Button Value: ");
Serial.println(buttonState);
}
delay(15);
}