# Beginner Coding Questions

**URL:** <https://forum.arduino.cc/t/beginner-coding-questions/1259568>\
**Category:** General Electronics\
**Created:** [May 13, 2024, 6:02pm UTC](https://forum.arduino.cc/t/beginner-coding-questions/1259568 "2024-05-13T18:02:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![king\_zark](https://avatars.discourse-cdn.com/v4/letter/k/3da27b/32.png) [@king\_zark](https://forum.arduino.cc/u/king_zark)\
**Post date:** [May 13, 2024, 6:02pm UTC](https://forum.arduino.cc/t/beginner-coding-questions/1259568/1 "2024-05-13T18:02:54Z")

</div>

I am just learning Arduino right now. I am trying to make a program where you push a button to turn on an LED using digitalWrite. However, when I push the button the LED stays on even once I have let go of the button. I am not sure what is wrong because I followed a tutorial for this program. I have attached my code and picture of the wiring.

 ![Screenshot 2024-05-13 105631](https://europe1.discourse-cdn.com/arduino/original/4X/e/2/5/e2558727b66b98cc2becc435b8755ba5dc990577.png)  
 ![IMG_8917](https://europe1.discourse-cdn.com/arduino/original/4X/e/b/0/eb084231770f1c893439e1f99affa9944701783b.jpeg)

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [May 13, 2024, 6:04pm UTC](https://forum.arduino.cc/t/beginner-coding-questions/1259568/2 "2024-05-13T18:04:30Z")

</div>

Never post screen shots of code, error messages or serial monitor output. Always copy the text of those things and paste it into your post using code tags. Thankyou.

---

<div class="post-metadata">

**Author:** ![camsysca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/camsysca/32/1015228_2.png) [@camsysca](https://forum.arduino.cc/u/camsysca)\
**Post date:** [May 13, 2024, 6:05pm UTC](https://forum.arduino.cc/t/beginner-coding-questions/1259568/3 "2024-05-13T18:05:25Z")

</div>

Welcome. While I'm sure you're impatient to get an answer, please go back and read the How to.

> [@How to get the best out of this forum](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/681356/1):
>
> Welcome to the Arduino forum! A guide explaining how to get the best out of this forum is available at the link below. Please read it:

In particular, DO NOT post code pictures. In the IDE, copy for forum, then paste into your message.  
Again, Welcome!

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [May 13, 2024, 6:08pm UTC](https://forum.arduino.cc/t/beginner-coding-questions/1259568/4 "2024-05-13T18:08:44Z")

</div>

Your button is wired incorrectly. Move the black wire to breadboard hole g20.

Better still, remove the resistor, the connection from 5V to the button, connect the black wire to the diagonally opposite pin of the button from the ground connection, and use mode INPUT\_PULLUP. The pin will read LOW when the button is pressed. This is not weird at all.

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [May 13, 2024, 6:20pm UTC](https://forum.arduino.cc/t/beginner-coding-questions/1259568/5 "2024-05-13T18:20:18Z")

</div>

FYI

 ![SwitchesAndLEDs](https://europe1.discourse-cdn.com/arduino/original/4X/7/e/0/7e0ee1e51f1df32e30893550c85f0dd33244fb0e.jpeg)

---

<div class="post-metadata">

**Author:** ![Grumpy\_Mike](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/grumpy_mike/32/213521_2.png) [@Grumpy\_Mike](https://forum.arduino.cc/u/Grumpy_Mike)\
**Post date:** [May 14, 2024, 5:57am UTC](https://forum.arduino.cc/t/beginner-coding-questions/1259568/6 "2024-05-14T05:57:43Z")

</div>

This post doesn't belong in the community section because it is not a community matter, it is a technical matter. Therefore I have moved it here.

Also it is not even a coding matter, but a hardware mistake you are making.

---

<div class="post-metadata">

**Author:** ![king\_zark](https://avatars.discourse-cdn.com/v4/letter/k/3da27b/32.png) [@king\_zark](https://forum.arduino.cc/u/king_zark)\
**Post date:** [May 14, 2024, 4:33pm UTC](https://forum.arduino.cc/t/beginner-coding-questions/1259568/7 "2024-05-14T16:33:10Z")

</div>

Sorry for posting in the wrong place. First time posting. I managed to fix it thanks to y'all. Appreciate the help

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [November 10, 2024, 4:33pm UTC](https://forum.arduino.cc/t/beginner-coding-questions/1259568/8 "2024-11-10T16:33:28Z")

</div>

Closed on November 10, 2024, 4:33pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
