Basic of Arduino..Interfacing Push Button to Arduino

  • Circuit Diagram
  • Components list:
  • Program:
  • Output:


                           


                 1.Resisters (1k and 100ohm)
                 2.LED
                 3.Push button
                 4.Arduino uno board



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         int buttonState = 0;         // variable for reading the pushbutton status
          void setup() 

         {    
         pinMode(13, OUTPUT);// initialize the LED pin as an output:
         pinMode(2, INPUT);// initialize the pushbutton pin as an input:
         }

        void loop() 
       {
           buttonState = digitalRead(buttonPin);// read the state of the pushbutton value:
           if (buttonState == LOW
                 {
                      digitalWrite(13, HIGH);// turn LED on:
                 }
         else 
                {
                     digitalWrite(13, LOW); // turn LED off:
                }
        }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

          watch this video for output.












Comments

Popular posts from this blog

Analog input Analog output of arduino

Arduino basic:How to get sub string from a string in arduino