AIM: To interface a digital input (push button) and blink and LED upon activation. COMPONENTS REQUIRED:
- 1 KΩ Resistor
- Arduino Uno
- Bread board
- USB Interfacing cable
- Jumper wires
- LED of choice THEORY : Arduino UNO The Uno is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. Technical specifications of Arduino UNO : Microcontroller ATmega168/328 Microcontroller ATmega168/328 Operating Voltage 5V Input Voltage (recommended) 7-12V Input Voltage (limits) 6-20V Digital I/O Pins 14 (of which 6 provide PWM output) Analog Input Pins 6 DC Current per I/O Pin 40 mA DC Current for 3.3V Pin 50 mA Flash Memory 16 KB (ATmega168) or 32 KB (ATmega328) of which 2 KB used by boot loader SRAM 1 KB (ATmega168) or 2 KB (ATmega328) EEPROM 512 bytes (ATmega168) or 1 KB (ATmega328) Clock Speed 16 MHz PIN DIAGRAM FOR ATMEGA 328
FIGURE-02 PROCEDURE Open tinker cad account
- Select Arduino uno , bread board , digital input and digital output
- Connect the circuit as given in the figure
- Develop the program and compile it for any errors
- .Execute the program
- Check the simulation
CIRCUIT DIAGRAM
FIGURE -03
PROGRAM
// C++ code
int ledpin=4;
int pushbtn=2;
int val=0;
void setup()
{
pinMode(ledpin, OUTPUT);
pinMode(pushbtn,INPUT);
}
void loop()
{
val=digitalRead(pushbtn);
if(val==0)
{
digitalWrite(ledpin,HIGH);
}
else
{
digitalWrite(ledpin,LOW);
}
}
BEFORE RUNNING THE SIMULATION:
Thus, we have interfaced a digital input (push button) and blink of LED upon activation.