Introduction
This experiment demonstrates how to use the ATmega328P microcontroller to control a digital output device (like an LED) based on the state of a push button.
Materials Required
- ATmega328P Microcontroller
- LED
- Resistor (220Ω)
- Push button
- Breadboard and jumper wires
- Arduino IDE
- USBasp Programmer or similar
No Ads Available.
Circuit Diagram
The following diagram shows how to connect the push button and LED to the ATmega328P:
Steps for the Experiment
- Connect the push button to an input pin on the ATmega328P and the LED to a digital output pin.
- Upload the program to read the button’s state and control the LED accordingly.
- Press the push button and observe the LED turning on and off.
Explanation
The ATmega328P reads the state of the push button. If the button is pressed, the microcontroller turns the LED on; otherwise, it turns it off.
Results and Observations
- The LED should light up when the push button is pressed and turn off when released.