Concept:
For this project, I decided to use one digital sensor and one analog sensor to control two LEDs. For the digital part, I connected a push button to a digital pin to control one LED — pressing the button turns the light on, and releasing it turns it off. For the analog part, I used a potentiometer connected to an analog input to control the brightness of a second LED through an analog output. As I turned the knob, the LED smoothly adjusted its brightness, demonstrating how analog signals can vary continuously instead of just turning on or off. This setup reflects the difference between digital and analog control and how both can work together in an interactive circuit.
Video Demonstration:
https://drive.google.com/file/d/1_urM0vEA__Piz7zGG_TUHDnuhy5QYUgQ/view?usp=drive_link
Circuit Illustration:
Code Highlight:
// Define pin numbers
int ledPin1 = 11; // LED controlled by potentiometer (analog LED)
int ledPin2 = 2; // LED controlled by button (digital LED)
int buttonPin = 7; // push button input
void setup() {
// Set pin modes
pinMode(ledPin1, OUTPUT); // pin 11 used for PWM (brightness control)
pinMode(ledPin2, OUTPUT); // pin 2 for digital on/off LED
pinMode(buttonPin, INPUT); // button as input (external resistor required)
Serial.begin(9600); // start serial monitor for debugging
}
void loop() {
// Read the potentiometer (analog sensor)
int sensorValue = analogRead(A1); // reads values from 0–1023
Serial.println(sensorValue); // print the reading to serial monitor
// Control the brightness of LED on pin 11
// analogWrite expects a range 0–255, so divide by 4 to scale down
analogWrite(ledPin1, sensorValue / 4);
delay(30); // small delay to stabilize readings
// Read the push button (digital sensor)
int buttonState = digitalRead(buttonPin); // reads HIGH or LOW
// Control the digital LED based on button state
if (buttonState == HIGH) { // if button is pressed (connected to 5V)
digitalWrite(ledPin2, HIGH); // turn LED on
}
else { // if button is not pressed (LOW)
digitalWrite(ledPin2, LOW); // turn LED off
}
}
Github Link:
Reflections & Future Improvements:
Working on this project helped me really understand the difference between digital and analog sensors and how they can control things like LEDs. I saw that a digital sensor, like a push button, only has two states — on or off — which makes it easy to control an LED directly. On the other hand, an analog sensor, like a potentiometer, can give a range of values, letting me gradually adjust the brightness of an LED. It was really satisfying to see how these two types of input behave so differently in a circuit.
If I were to improve the project, I’d try adding more interactive elements. For example, I could use multiple buttons or potentiometers to control more LEDs, or even combine the potentiometer with a light sensor so the LED responds to changes in the environment automatically. I’d also like to experiment with different LED effects, like fading, blinking patterns, or color changes, to make it more dynamic and fun. Overall, this project gave me a better understanding of how simple inputs can be used creatively to make interactive circuits.
