How to Use a Button with an Arduino (Lesson #5)

  Рет қаралды 63,908

Science Buddies

Science Buddies

Күн бұрын

Science Buddies Electronics Kit for Arduino: www.homesciencetools.com/prod...
Learn how to use a button as a digital input to an Arduino I/O pin with the digitalRead command. See our complete playlist of Arduino tutorials here: • How to Use an Arduino and the Science Buddies website for cool science projects you can do with an Arduino: www.sciencebuddies.org/search....
0:00 intro
0:23 materials
0:37 algorithm: pseudocode
1:31 algorithm: flowchart
2:22 build the circuit
8:29 connect a pull-down resistor
9:54 write the code
13:59 test your code
14:19 reverse button behavior
16:18 variables
20:40 up next
Science Buddies also hosts a library of instructions for over 1,500 other hands-on science projects, lesson plans, and fun activities for K-12 parents, students, and teachers! Visit us at www.sciencebuddies.org to learn more.
#STEM #sciencebuddies #arduino #electronics #programming
*******************************
Connect with Science Buddies:
TWITTER: / sciencebuddies
FACEBOOK: / sciencebuddies
INSTAGRAM: / scibuddy
PINTEREST: / sciencebuddies

Пікірлер: 54
@casual2531
@casual2531 2 ай бұрын
You have no idea how much you have taught me, thank you brother. I love the way you explain stuff. May God bless you.
@eternitysf3413
@eternitysf3413 3 ай бұрын
You explained very well! thank you so much!
@azatturegeldin4716
@azatturegeldin4716 3 ай бұрын
A brilliant explanation. I was reading a book where I had a similar project with a button and a capacitor. I couldn't implement it properly, and this video helped me a lot!
@aaronjeffery7123
@aaronjeffery7123 2 ай бұрын
Your vidios in the ardiuno series are amazing.Keep it up bro
@farbodkeyhanloo906
@farbodkeyhanloo906 8 ай бұрын
This is amazing! Thank you!
@CaffineAndCode
@CaffineAndCode 7 ай бұрын
Amazing explanation
@AayushGupta-uj6hx
@AayushGupta-uj6hx 21 күн бұрын
Bro you explain the best. 👍👍👍
@daveluvs3dprinters
@daveluvs3dprinters 3 ай бұрын
i love your videos ☺
@Lucky_Trucky
@Lucky_Trucky Жыл бұрын
Suggest another videos with pushbuttons: what about pushing for stay on/off, press short and long, press x times to do this and y times to do that in 5 seconds, ....
@Science.Buddies
@Science.Buddies Жыл бұрын
Thanks for the suggestion! We will be adding more Arduino tutorials in the future, stay tuned!
@user-nv3sb5hr2f
@user-nv3sb5hr2f Ай бұрын
thank uu
@spurfy8392
@spurfy8392 4 ай бұрын
how did we know if we connect the LED, at the PIN + or a the - one ? Does it will change something ? Or the voltage juste will be inversed ?
@Science.Buddies
@Science.Buddies 4 ай бұрын
We recommend watching our video about LEDs before this one, it may answer your questions: kzbin.info/www/bejne/fHzInK2wn5prapYsi=VWlZPUgTYETmyjXP
@behem05
@behem05 7 ай бұрын
what do i need to edit in order to replace the led with variables?
@Science.Buddies
@Science.Buddies 7 ай бұрын
If you watch to the end of the video (starting around 16:20) we cover using variables in the code.
@amirarab254
@amirarab254 2 ай бұрын
Hello and thank you very much for the great video. Nevertheless I have a question: why do I have to connect the button anyway to the ground. When I don’t push the button, there is no current flow and the input to the PIN is low. Why is the connection to the ground necessary? Than you
@Science.Buddies
@Science.Buddies 2 ай бұрын
The connection to ground is needed so the input pin voltage is never "floating" or undetermined. This way it is always either 0V or 5V. If the pin is not connected to anything then it can be affected by electrical noise from other things in the circuit and nearby pins.
@amirarab254
@amirarab254 2 ай бұрын
Thank you very much
@harishanth.r732
@harishanth.r732 3 ай бұрын
What will happen if place the switch on one side? And if we place switch in such a way that the legs are placed on two side.how it gets current or voltage to all legs since the two sides are separated by a plastic? insulator?
@thatphysicsguy7859
@thatphysicsguy7859 3 ай бұрын
im pretty sure its because the button takes up a lot of space on one side which doesnt allow us to use more wires in the same row(like when he used the resistor and jumper in the same row for the button)
@G18-ROQUEPRECIOUSZOEA.
@G18-ROQUEPRECIOUSZOEA. 4 ай бұрын
How is it when pushing the buttons to stay on/off? Im having a science project where i need an arduino to control the temperature of my desired heat/cold. Please respond...
@Science.Buddies
@Science.Buddies 4 ай бұрын
Hi - if you search online for "Arduino button toggle" you should find example code that lets you push to toggle the button instead of holding it down. You can also look at our list of tutorials and use a slide switch instead of a button.
@SyntaxError-2505
@SyntaxError-2505 2 ай бұрын
I have a question. Can I just make the button let the electricity flow between the LED and the GND-bus? It wouldn't need as much code
@Science.Buddies
@Science.Buddies 2 ай бұрын
Hi - if all you want to do is turn on an LED when you hold the button down, then you do not need an Arduino at all. An Arduino allows you to program more complicated behaviors, user other sensors, and control outputs like motors. You can find more information in the Arduino playlist linked in the video description.
@travisborges1048
@travisborges1048 2 ай бұрын
im not sure if this is right but it worked for me insted of == i put a single - and it does the same this.
@Science.Buddies
@Science.Buddies 2 ай бұрын
== is called a "comparison operator" and a single = is called an "assignment operator" - you can learn more about this in the Arduino language reference: www.arduino.cc/reference/en/
@anjiiro610
@anjiiro610 3 ай бұрын
Hello i have a question, how come does my LED is turned on even, i haven't pushed the button, while if i pushed the button, it just glows brighter? i just followed the commands TYIA!
@Science.Buddies
@Science.Buddies 3 ай бұрын
You may have the pin set as an input instead of an output - double check that your code AND your circuit follow what is shown in the video.
@ArzenikRawr
@ArzenikRawr 5 ай бұрын
I made it so when pressed green led goes on when not pressed red led goes on
@micahbentley2233
@micahbentley2233 5 ай бұрын
How?
@ArzenikRawr
@ArzenikRawr 5 ай бұрын
@@micahbentley2233 you use the scripts from first in the if statement and make one go high if pressed and one go low then in the else you make on go low and one go high
@kushalm7328
@kushalm7328 5 ай бұрын
me too😀
@micahbentley2233
@micahbentley2233 5 ай бұрын
nvm, you can make this with no arduino, just a relay. how did I do that?
@tomekpro2918
@tomekpro2918 5 ай бұрын
change line: (digitalRead(button_Pin)==LOW) on this one (digitalRead(button_Pin)==HIGH) - will be ok now.
@dataeater1319
@dataeater1319 Ай бұрын
In my exam I’m gonna have to use 9 buttons and a display I don’t have enough pin mode what do I do ?
@Science.Buddies
@Science.Buddies Ай бұрын
Hi - you may have more luck asking this question on the official Arduino forums.
@marvelqueen52
@marvelqueen52 Ай бұрын
It worked in tinkercard but it didn't work in real life
@rrssmooth6643
@rrssmooth6643 3 ай бұрын
gee I wish when people write the code, they make it bigger to be able to see the code.
@__KursK__
@__KursK__ 2 ай бұрын
Couldnt you just use the button as an circuit breaker instead of using code? Seems simpler but the code one is cooler
@Science.Buddies
@Science.Buddies 2 ай бұрын
Yes, if all you want is on/off control of a single LED using a button, then technically you do not need the Arduino at all, but if you want to do anything more complicated (like making multiple LEDs flash in a pattern when you push a button once) then it becomes much easier to do with code.
@__KursK__
@__KursK__ 2 ай бұрын
@@Science.Buddies Yeah, that's true. Even through, you might be able to do it with like logic Gates or relais
@Science.Buddies
@Science.Buddies 2 ай бұрын
Right - you can hard-wire plenty of interesting circuit behaviors without any code at all. For example, check out the "Bluebot" series of projects on our site, which have both Arduino and non-Arduino versions. The non-Arduino versions can do basic left-right steering using different sensor inputs despite not having any microcontroller: www.sciencebuddies.org/science-fair-projects/science-projects?s=bluebot
@user-ld5gx1zx8v
@user-ld5gx1zx8v 4 ай бұрын
It doesn't work
@123nody
@123nody 3 ай бұрын
Same for me
@123nody
@123nody 3 ай бұрын
it works on the tinkercad sim, but on the board it doesn't. I debugged it but still nothing
@sadhgunavarshinie7281
@sadhgunavarshinie7281 3 ай бұрын
Check the other vid about debugging arduino in this playlist
@RJkatztabby
@RJkatztabby 23 күн бұрын
I copied the code and it won't compile. This is bullshit!
@IplayGames24seven
@IplayGames24seven 2 ай бұрын
I dont have a PC 😡
@Science.Buddies
@Science.Buddies 2 ай бұрын
You can also program an Arduino from a Mac! See the software options here: www.arduino.cc/en/software
@bimbo-yw6ny
@bimbo-yw6ny 2 күн бұрын
but if arduino output is only 250mamps, what's the point to use all these resistors, currrent is limited, and the board is suppose has a resistor to stop overflow of current back to the pin? i've tried without resistors, nothing bad happens, the board is still working.
@bimbo-yw6ny
@bimbo-yw6ny 2 күн бұрын
why the 10kohms resistor??
@bimbo-yw6ny
@bimbo-yw6ny 2 күн бұрын
i'm sorry i followed the video, i got the explanation, not to short the 5v to the pin with a 10k resistor.
How to Fade an LED with Arduino analogWrite (Lesson #6)
11:13
Science Buddies
Рет қаралды 27 М.
How to Use a Breadboard
12:21
Science Buddies
Рет қаралды 3 МЛН
⬅️🤔➡️
00:31
Celine Dept
Рет қаралды 49 МЛН
He sees meat everywhere 😄🥩
00:11
AngLova
Рет қаралды 8 МЛН
Универ. 13 лет спустя - ВСЕ СЕРИИ ПОДРЯД
9:07:11
Комедии 2023
Рет қаралды 6 МЛН
How To Wire It! Buttons & Switches
9:52
ItKindaWorks
Рет қаралды 129 М.
Control a DC Motor with Arduino (Lesson #16)
14:01
Science Buddies
Рет қаралды 178 М.
How to use a BreadBoard - Electronics Basics 10
7:22
Simply Electronics
Рет қаралды 833 М.
Arduino Tutorial 34: Simplest Way to Use a Pushbutton Switch
10:26
Paul McWhorter
Рет қаралды 96 М.
How to Organize Code
14:37
Programming Electronics Academy
Рет қаралды 60 М.
You can learn Arduino in 15 minutes.
16:34
Afrotechmods
Рет қаралды 9 МЛН
Arduino Tutorial 28: Using a Pushbutton as a Toggle Switch
21:58
Paul McWhorter
Рет қаралды 285 М.
How to Use Arduino Interrupts The Easy Way
33:28
Rachel De Barros
Рет қаралды 76 М.
⬅️🤔➡️
00:31
Celine Dept
Рет қаралды 49 МЛН