Electric logic question

Hi. I just started Arduino and i have a question in my mind. I did the button-led project by following these instructions(photo). I see that we use the button my starting the connection by "+" and ending in "-" but for the led we start from "+" and end in nowhere just goes to the Arduino pin. I tested this, it worked without issue. My question is why we don't need to end the led in "-" side, or maybe i did it wrong. Thanks.

led4_bb.png

No, sorry, don't understand the question

It doesn't matter which side of the LED that the resistor is connected, as long as it's in series with the led.

dlloyd:
It doesn't matter which side of the LED that the resistor is connected, as long as it's in series with the led.

Actually, I didnt mean the resistor. If im correct current starts from the positive line on the breadboard passes through the button and ends in the negative line. On the other hand current comes to the led from positive but ends with going to the Arduino pin. Shouldnt i make a connection led between the negative line ?

The pin, when in output mode, does the switching to the negative line (GND) when it goes LOW.

No, you shouldn't connect the led to ground.

You are not following what is happening in your circuit.

The button. --The resistor is a pull-up resistor. It's purpose is twofold , one, to limit the amount of current from the positive rail to ground when the button is pushed, and 2- is to bring the line to the I/O pin high (5v) when the button is NOT pushed.

As for the led, it is getting it's power from the I/O pin, which is controlled by the sketch (on/off). The resistor limits the amount of current through the led AND the I/O pin. Too much current through either will destroy them.
edited to correct

Kalender:
Shouldnt i make a connection led between the negative line ?

Only if you want the LED to be on all the time without having any control from your Arduino.

The difference between the button and the LED is that one is being read by an input and the other is being controlled by an output. If you connected the button in the same way as the LED, the input would be left floating when the button was not pressed and so you would be left with an indeterminate state.

If you try searching for the term "pull-up resistor", it might be helpful to understand more.

On the other hand current comes to the led from positive but ends with going to the Arduino pin. Shouldnt i make a connection led between the negative line?

The way you've got it wired, current flows through the LED and resistor to ground.

And, that's correct. You don't want the LED wired directly across +5V and ground because it will get over-voltaged and you'll draw too much current. The resistor limits the current (and it allows the LED voltage to "fall into place").

The OP is obviously woefully ignorant of the simplest basics of electronics ( I don't mean to be rude).

Is there a modern reasonably priced book or on-line introductory text which could get him started?

regards Allan

allanhurst:
The OP is obviously woefully ignorant of the simplest basics of electronics ( I don't mean to be rude).

Is there a modern reasonably priced book or on-line introductory text which could get him started?

regards Allan

Not as bad as I was. When I was 7yo, I tried to electrify my piggybank by wrapping a coat hanger around it and stuffing it into the wall outlet.....

I got my but beat and grounded for a month over 79 cents

Would you recommend "Getting started in electronics" book ?

Kalender:
Hi. I just started Arduino and i have a question in my mind. I did the button-led project by following these instructions(photo). I see that we use the button my starting the connection by "+" and ending in "-" but for the led we start from "+" and end in nowhere just goes to the Arduino pin. I tested this, it worked without issue. My question is why we don't need to end the led in "-" side, or maybe i did it wrong. Thanks.

The pin driving the LED sources current, that current flows through LED, resistor, to ground. That's the LED
circuit, from pin to ground. Inside the chip there is a transistor that switches the pin to 5V to set the pin HIGH.

The switch circuit has an unnecessary pull up resistor, because the chip already has pull-up resistors built in
on each pin, you just have to specify pinMode (pin, INPUT_PULLUP); then you wouldn't need
the resistor to +5V on the switch on your breadboard.

Google 'gcse electronics textbook' - there are lots of books and online resources there

Allan

tinman13kup:
Not as bad as I was. When I was 7yo, I tried to electrify my piggybank by wrapping a coat hanger around it and stuffing it into the wall outlet.....

I got my but beat and grounded for a month over 79 cents

And you know...stupidly endangering your own life and risking starting a fire. Might be worth a bit more than 79 cents.