Saturday, January 11, 2020

Button LED with Arduino Uno


Here is very Basic Project with for my DAE Electronics 3rd year students just for Arduino learning purpose. Its also helpful article for those who are new with Arduino.

In this Practical following components are used.
1. Arduino Uno
2. LED
3. Button
4. Resister 10K Ohm  
5. Connecting wires
but here is my circuit is for Proteus simulation (as shown in diaram).
    


Arduino Proramming Body have three parts.

Declaration area:

Int sw = 6;     // the number of the pushbutton pin
led =  12;      // the number of the LED pin

int swread = 0;         // variable for reading the pushbutton status

I/O Defining Area:

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

  }

Main Program Body:


void loop() 
{

  swread = digitalRead(sw);     // read the state of the pushbutton value:

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


So as whole is here:

if you like article so like and share it.

No comments:
Write comments

I am very thankful for your precious time

Important Artical

Popular Articals

Total Page views in This Month

© 2019-20 Electronics Garage. Designed by Uzma 0101 & Distributed by elektronicsgarage1.blogspot.com