Arduino digitalRead Serial Monitor with Button

preview_player
Показать описание
Arduino Basic Tutorial digitalRead Serial Monitor with Button. Reads a digital input on pin 2, prints the result to the serial monitor.

When the pushbutton is open (unpressed) there is no connection between the two legs of the pushbutton, so the pin is connected to ground (through the pull-down resistor) and reads as LOW, or 0.
When the button is closed (pressed), it makes a connection between its two legs, connecting the pin to 5 volts, so that the pin reads as HIGH, or 1.

Required Hardware

Recommended Items:

Connections
One leg of the button connect a resistor.
Green wire connect from digital pin 2 to one leg of the pushbutton.
Leg of the resistor to ground.
The other leg of the button connects to the 5 volt supply.

Social Media:
Рекомендации по теме
Комментарии
Автор

Friend, thank you very much. This video of yours has saved me the semester in school, it has saved me from a fight with classmates and I may even get a girlfriend. You're the best. You have a new subscriber and lifelong admirer.

robertosalgado
Автор

Bütün gün aradım buldum sende oldugunu daha yeni görüyorum bundan sonra ilk sana bakacağım 😂 ( internette çok karmaşıkları var ve dataylı anlatım yok tebrikler )

kaanekz
Автор

Great video man
total rocking
I was inspired by this video

abhijaypratapsinghtanwar
Автор

I have a question to ask, please
How does the pin(2) attached to the third leg realizes that the two legs of the push button are connected when the button is pressed ?!! in another form: How does the 4-legs are connected to each others ?
thank you

abdelrahmanellithy
Автор

i LoVe your videos.. & the music u used

namesarefools
Автор

sweet video, would this be good to test the esp32 port serial2 with a rs485 ttl module? 😊 thank you

qzorn
Автор

Hi, I started doing the same on my Arduino, But I'm trying to read if the LED is ON (1) or OFF (2), But i cant make it work :(

pccxp
Автор

Connections:
Switch: left side vertical pins (1 & 2). Connect pin 1 to 5v, pin 2 no connect.
Switch: right side vertical pins (3 & 4). Connect pin 3 to R1 (10K). Connect R1's other end to Gnd
Connect switch pin 4 to Arduino pin 2
/*Digital Read with Button:
Upload sketch then open Serial Monitor (9600): a "0" will appear on each update.
If the button is pushed a "1 will appear on each update until the button is released.
Close the Serial Monitor & open the Serial Plotter (Tools, Serial Plotter).
A trace line will appear indicating "0" level.
Push & hold the button. The trace line will now indicate "1" until the button is released
*/
int pushButton = 2;

void setup () {
Serial.begin (9600);
pinMode (pushButton, INPUT);
}
void loop () {
int buttonState = digitalRead (pushButton); //read input pin
Serial.println (buttonState); // print state of button
delay (1);
}

lastchance
Автор

can you do the same code but with a LCD shield and have the serial monitor read the buttons on a LCD shield?

taranagnew
Автор

how to serial monitor two button? press button 1- monitor 1, if press button 2- monitor 2...

PP-ygll
Автор

Kralsın allah razı olsun kaç saattir bunu ariyom

ahmetberakarasoy
Автор

My curve looks very different, unfortunately. When I don't touch it, it draws something similar do a sin-wave. When I press the button, the amplitude is zero. Where did I do something wrong?

silentsniper
Автор

merhabalar hocam.bir projem için sizden yardım isticem. motosikletim için arduino üzerine kurulu bir ekran projesi yaptım sonlandırdım ancak button eklemem lazım su geçirmez falan olsun istiyorum aliexpresste görebildiğim kadarıyla on/off durumlu buttonlar var bu arduinoda kulllandığımız gibi çıtçıtlı digital veri alabildiğimiz buttonlardan yok. sizce nasıl bir yol izlemeliyim?

suloman
Автор

kindly don't forget the esp8266 robo

kartiksingh
Автор

sir why are you add 10k ohm resister with button to ground
reply please i want to know

mightydead
Автор

It is so difficult for those watching ur vedio through the mobile to see the code .

engjawad
Автор

i wanna get circuit please give me them.

_red_shift
Автор

fxxckjing I haven't understand yet.

김사장-sv
Автор

One minute to put a button on a board? F*

bob-nykn
join shbcf.ru