matthewkohn6
Published

Simple LED Button

When you press the button, the LED turns on, Using a Snapino UNO!

BeginnerProtip219
Simple LED Button

Things used in this project

Hardware components

LED
×1
Button
×1
Alligator Clips
×2

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

button_code

Arduino
This code will be the only code you will need. This will tell the computer or microcontroller that pinmode
void setup() {
  //button1
  pinMode(9,INPUT);
  //led1
  pinMode(3,OUTPUT);
}

void loop() {
  if(digitalRead(2)==LOW){
    digitalWrite(3,HIGH);
  }
}

button_code

Arduino
This code will be the only code you will need. This will tell the computer or microcontroller that pinmode 9 is connected to the button and the led is connected to pinmode 3. The microcontroller will constantly be checking if pin 2 is low. If pin 2 is low, pin three goes high.
void setup() {
  //button1
  pinMode(9,INPUT);
  //led1
  pinMode(3,OUTPUT);
}

void loop() {
  if(digitalRead(2)==LOW){
    digitalWrite(3,HIGH);
  }
}

Credits

matthewkohn6
1 project • 0 followers

Comments