Arduino Tutorial #1 - Digital Inputs and Outputs - Button & LED

preview_player
Показать описание
Contribute:

In this tutorial I show you how to build three basic projects with the Arduino.

The first one is a simple blinking LED which is already on the board.
The second one involves connecting an LED onto the breadboard with a current limiting resistor.
The last one is a button which is used to control the on/off state of our LED.

Make sure to comment, rate and subscribe to my channel; stay tuned for more tutorials.

Search Terms and Keywords:
Arduino
Arduino Tutorial
Arduino Getting Started
Basic Arduino
Arduino Class
Arduino Hardware
Arduino Software
Arduino Code
Arduino Example
Arduino Project
Arduino How To
Arduino LED
Arduino Push Button
Push Button
Light Emitting Diaode
Atmega
Atmega328
Tutorial
Basic Hardware
Electronics
Electrical Engineering
Electronic Circuit
Simple Arduino Projects
Рекомендации по теме
Комментарии
Автор

I made a little variation just to wrap my head around the code part. This is supposed to blink the LED half second with button not pressed, and simply blink faster when you press the button...

int LED = 12;
int BUTTON = 4;

void setup()
{
  pinMode (LED, OUTPUT);
  pinMode (BUTTON, INPUT);
}

void loop()
{
  if(digitalRead(BUTTON) == HIGH)
  {
  digitalWrite(LED, HIGH);
  delay(50);
  digitalWrite(LED, LOW);
  delay(50);
  }else
  {
    digitalWrite(LED, HIGH);
    delay(500);
    digitalWrite(LED, LOW);
    delay(500);
  }
}

girardaquino
Автор

dude, thanks a lot. you save my life to finish up my digital project using this arduino. haha

YuiSenpai
Автор

Great Tutorial EEEnthusiast, I just have 2 questions: What is the purpose for the resistors? and What program did u simulate the breadboard and arduino in? Thanks again for the great tutorial.

Skitmaster
Автор

Arduino arrived and hour ago. I just followed your tutorial and made the onboard led blink faster. It was unexpectedly exciting and wonderful!

dimwoo
Автор

Thanks! I just built it and I feel so happy :) This is my first step and though it isn't something that great, making a LED bulb light up feels amazinggg

ellieqle
Автор

mine doesent work that great, just seems to output a dimmer LED light when the buttons not pressed, any ideas?

lukes
Автор

Thanks! My 5 year old followed your instructions and made his first Arduino project! Thanks!

fprada
Автор

Noob question: Why do you put the resistor going from the negative pin of the LED to the GND? Don't you want the resistor to resist the current going from the digital pin to the LED?

theyoungone
Автор

does the button short the pin to ground or does the input have a resistor value?

jamesmclaughlinprimitivele
Автор

How do you calculate the resistor value

manikandankannan
Автор

While I am all for DRY programming. Defining LED as 13 is going to consume 13 more bytes than needed in memory. Thank's for the tutorial though! :)

kamarilabs
Автор

Ca you please give a download link for the software you have

AT 2:41

fineilldoitmyself
Автор

In my case there is an error in code
" else without an previous 'if' "
I have written the same way as you did

dharmitshah
Автор

Really nice tutorial, thanks a lot mate =)
I few questions that I was hoping you might be able to answer for me though:

1. What is approximately the output voltage of the pins when they are set to HIGH? Is there any way to increase/decrease this output voltage

2. Do all output pins connect back to the Arduino via the same ground? Say if I'm working on a project where I will set pins 1, 5 and 12 to HIGH - should these all be connected to the same ground to form full circuits?

Hope you will answer! ^_^

Ashadow
Автор

Thanks man, followed exactly and works like a charm for me :)

arnoldswagger
Автор

I have a claw machine, which i would like to setup something like this to move the claw and drop the claw by using my computers keyboard. Any ideas, where to start?.

melannieworld
Автор

Steven Yang wrote this comment:

"lol I wrote the switch program like this:
digitalRead (BUTTON);
if (BUTTON == HIGH); {
//do whatever here;
} else {
//do whatever is here;
}"

I can't reply to Steven's comment, so I'll do it here.

This won't work, because he reads the button but doesn't assign the read value to anything, so that value is lost. Instead of the read value Steven now compares the value BUTTON instead of the value *OF* BUTTON. BUTTON has been defined as "4", which isn't the same as HIGH (which is "1"), so it will always be the "else" part of the code which is executed.

stevenvanhulle
Автор

excuse me sir bt i"m a little bit new to arduino. could u xplain me why do we use a resistor wid a led?

pratyush
Автор

I have  a problem with my code
void setup() {
  // put your setup code here, to run once:
  pinMode(12, OUTPUT);
  pinMode(8, INPUT);
  pinMode(13, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
 digitalWrite(12, HIGH);
 if(digitalWrite(8)==LOW)
{ digitalWrite(13, HIGH);
}
 else
{ digitalWrite(13, LOW);
}
}
it  says  that  there is a  compile  error  and I  can't find  it, please help  me.

tigranbalanyan
Автор

-watch my new video: Arduino Joystick Tutorial | How To Control An LED with Joystick
השב

workmuscles