Arduino Beginner Series: Project 6: Turn LED on with switch

Hello everyone!! Welcome to this post on Arduino Projects!!
Need a short introduction to what the Arduino is then click on LINK
Check out the breadboard intro right HERE

So in this project we’ll see how to turn LED on with the help of a switch

Demo:

This is what my project looks like:

Things Required:

  1. Arduino UNO
  2. USB AB cable
  3. LED (any color)
  4. Breadboard
  5. 220 ohm resistor
  6. Arduino IDE on computer
  7. jumper wires

Functions used:

  1. digitalRead()
  2. digitalWrite()
  3. delay()

Video Tutorial:

I used this video as a reference: (LINK)

Code:

int led= 9;
int button= 8;
int dt=100;
int buttonread;

void setup() {
  // put your setup code here, to run once:
  pinMode(led, OUTPUT);
  pinMode(button, INPUT);
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
  buttonread= digitalRead(button);
  Serial.println(buttonread);
  
  if (buttonread==1){
    digitalWrite(led,LOW);
  }

  if(buttonread==0){
    digitalWrite(led, HIGH);
  }

  delay(dt); 

}

Stay Tuned for upcoming posts on Arduino Projects! We’re on the basic newbie projects right now and slowly, gradually move on to those cool, ultra techy projects!! Want to be the first to know when a new and amazing post comes up?? Then feel free to subscribe!

Happy Learning!!

Leave a Reply

PHP JS HTML CSS BASH PYTHON CODE

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: