PUSH BUTTON:
- The push button is a component and connects the two points.
- The first pin the push button is connected to a 5 volt supply.
- The second pin the push button is connected to gnd.

Figure1: PushButton
Required Materials
- Arduino Uno board
- Push-button
- Led
- Breadboard
- Hook up wires
- USB cable
Step 1: Push-button connection,
- The first pin the push button is connected to a 5 volt supply.
- The second pin the push button is connected to gnd and to digital pin 03.
- The LED has a positive and a negative point.
- The positive point of LED is connected to a digital pin 13.
- The negative points connected to a gnd
Connect the Arduino board to your computer with the USB cable and start sketching the following program,
Step 3: Programming
- int led = 13;
- int PinButton = 4;
- void setup()
- {
- pinMode(PinButton, INPUT);
- pinMode(led, OUTPUT);
- }
- void loop()
- {
- int stateButton = digitalRead(PinButton);
- if (stateButton == 1)
- {
- digitalWrite(led, HIGH); // Turn on led
- }
- else
- {
- digitalWrite(led, LOW); //Turn off led
- }
- delay(20);
- }
Explanation
Declare the variables: led, PinButtons and assign the value to that and in the setup() function set the button as the INPUT and led as the OUTPUT
and in the loop() function stateButton=digitalRead(PinButton). It reads the state of the push button value and if (stateButton==1) it means to check if the push button is pressed and if the button state will be HIGH, then the led will glow and if it is not that means led will not glow.


Vignesh ManiTOP 100Posted Feb 6, 2016, 12:17 PM EST
Good one
Jaco ZwartsPosted Jan 30, 2016, 3:27 AM EST
Nice thank you for sharing
Sr KarthigaPosted Jan 6, 2016, 2:41 PM EST
Thanks to all
Joe WilsonPosted Jan 6, 2016, 12:00 AM EST
Thank you for sharing.
Santhakumar MunuswamyPosted Jan 5, 2016, 6:03 PM EST
Thanks for nice share
Gowtham RajamanickamTOP 100Posted Jan 5, 2016, 2:22 AM EST
Good article
Karthikeyan KPosted Jan 4, 2016, 10:05 PM EST
Good one..Thanks for sharing
Ankur MistryTOP 100Posted Jan 4, 2016, 9:53 PM EST
Nice share
Kumaresh RajalingamPosted Jan 4, 2016, 9:39 PM EST
Good one
Shridhar SharmaPosted Jan 4, 2016, 8:49 PM EST
nice share
Ankit BansalPosted Jan 4, 2016, 8:44 PM EST
nice..