Hello Iam Newbie! I need help for my arduino

I just start study prigramming, and i am korean. I am hard to english, Sorry.

I was write code in arduino:

int d;

void setup() {
pinMode(2, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(7, OUTPUT);
Serial.begin(9600);
d = 0;
}
void loop() {
if(digitalRead(4) == LOW)
d = 1;

   if(digitalRead(2) == LOW)
   d = 0;

   if(d == 1)
   digitalWrite(7, HIGH);

   if(d == 0)
   digitalWrite(7, LOW);
   
   Serial.println(d);

}

And i test it
But i was surprised
Because i push off button(2), … Led is bright…?
And push off, led is off again, i want hold turn on the light.

So i push on button(4), … Nothing…
Pls, i am newbie and korean
Dont hate me :sob:

Hi @NoobProgrammer32, and welcome to the community!

Although I’m sure you’ll find many Arduino programmers here, my advise would be to look for support in an Arduino-specific community, where your question has less risk of going by unnoticed, and where the chances of finding people with the right expertise to answer you are higher — the Arduino experts you’ll find here are most likely also members of Arduino-specific forums anyway.

nothing to be sorry about. I’m sure you’ll find other Korean speaking users here. You can always avail yourself of the help of online translators:

https://www.translate.com/korean-english

As for the Arduino question, I’m afraid I can’t help you with that.

1 Like

Oh, github is not support arduino… Thanks!

I didn’t say that. Don’t get me wrong. I’m just saying that at the official Arduino community you’re likely to find better and quicker support:

1 Like

Hy,
why did you draw the connexions that complicate?
For me it seams to be ok, but it can be drawn much simpler.
And with the program I also can’t help much, but it seams, that you ask for low, not for high. If butom is open, input is low, so you have to ask for high, not for low to detect pushing.
Did you finde help in the links?

Try this:

if(digitalRead(4) == HIGH)
d = 1;

if(digitalRead(2) == HIGH)
d = 0;

2 Likes

Oh Thank you very much!

Hello,
did it work?

Regards