How to Blink LED with Arduino and PushButton | | Blink LED using pushbutton and Arduino UNO | |


Hello Friends! Welcome back to 'INNOVATIVE SCIENTIFIC INVENTIONS'. Today I will show you. How to Blink LED with Arduino and PUSHBUTTON.




Circuit Diagram:



Code:

                   //CODE\\
  /*
  Button

  Turns on and off a light emitting diode(LED) connected to digital pin 13,
  when pressing a pushbutton attached to pin 2.

  The circuit:
  - LED attached from pin 13 to ground
  - pushbutton attached to pin 2 from +5V
  - 10K resistor attached to pin 2 from ground

  - Note: on most Arduinos there is already an LED on the board
    attached to pin 13.

  created 2005
  by DojoDave <http://www.0j0.org>
  modified 30 Aug 2011
  by Tom Igoe

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/Button
*/

// constants won't change. They're used here to set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  } else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}






What do you need to Create this Project:


  1. Arduino UNO R3
  2. LED
  3. PushButton
  4. 10K Ohms Resistor
  5. Bread Board
  6. Jumping Wires


Purchase Products:



How to Upload Code in Arduino:
  1. Open Arduino IDE.
  2. Paste the code in Arduino IDE.
  3. Compile the Code.
  4. Upload the Code on Board.


How to Select Board:
  1. Open Arduino IDE
  2. Click on 'Tools' Option
  3. Click on 'Board'
  4. Select your Board


How to Select Port:
  1. Open Arduino IDE
  2. Click on 'Tools' Option
  3. Click on 'Port'
  4. Select your Port

How to Save Sketch in Computer:
  1. Open Arduino IDE
  2. Click on 'File' Option
  3. Click on 'Save' Option
  4. Select your Folder

How to 'Save as' Sketch:
  1. Open Arduino IDE
  2. Click on 'File' Option
  3. Click on 'Save as' Option
  4. Select your Folder

IF YOU WANT TO DONATE FOR "INNOVATIVE SCIENTIFIC INVENTIONS" SO PLEASE CONTACT ME.

WHATSAPP: +923110084691

EASY PAISA: +923327810553




           
   Click Here to Download Arduino IDE 
Arduino IDE Download Link:

Post a Comment

0 Comments