// Pin definitions
const int buttonPin = 2; // Connect a push button to pin 2
const int potentiometerPin = A0; // Connect a potentiometer to analog pin A0
const int ledPin = 13; // Connect an LED to pin 13
// Variables
int buttonState = 0;
int potValue = 0;
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
// No wiring is needed for the potentiometer as it is an analog input
}
void loop() {
// Read the state of the button
buttonState = digitalRead(buttonPin);
// Read the value of the potentiometer
potValue = analogRead(potentiometerPin);
// Turn on the LED if the button is pressed
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}