I don't understand some points on the project 2.
When you finish to build the project and just launch it, the LED is green and the arduino pin has received a LOW info.
But, how it's possible because of the switch? The switch is opened so there is no path from 5V to ground or the the arduino pin.
Also, the 10k resistor is after the n°2 green wire so it should received 5V and only the ground should receive less. Am I wrong?
Last point, is the 10k resistor is usefull for the arduino pin because it doesn't accept to receive directly 5V?
Thank you so much,
The 10 K resistor is there to insure that pin 2 is low when no switch is pressed without it pin 2 could float around from high to low. And in a low condition the sketch makes pin 3 high which turns on the green (you could make pin 4 or 5 high instead.) When you press the switch it sends 5 volt to pin 2 making it high and turning on other LEDs. One end of 10k is tied to gnd the other pin 2 there are internal circuits inside the Uno tied to pin 2 and as long as the switch is open it remains low
Thank you @rogertee but not sure to understand this quote.
One end of 10k is tied to gnd the other pin 2 there are internal circuits inside the Uno tied to pin 2 and as long as the switch is open it remains low
My only concern is to understand how pin2 can receive the low information without receiving electricity because there is not path(because of the switch opened) from 5v to GND... You said the pin2 can float but how is it possible without electricity?
Could you enlight me please? :)
The little microprocessor on the Arduino board has a mess of circuits inside of it if you study the basics of semiconductors and integrated circuits you would see that just touching a wire on a transistor can affect a circuit. Due to the voltage level of a low signal below 1 volt and a high signal at 3 volts and the input impedance of the pin we can use a 10K resistor to hold that pin to a low condition and when we apply 5v it over rides the 10k and makes that pin high. you could hook that 10K to 5v and pin 2 in which case you sketch if statement would be reversed and the red Leds would be on because the default for pin 2 would be high and the switch would now be tied to ground. For more info study the learning reference guide above and look at input pull up to get a better understanding. Another thing you should get is a book on Arduino there are several good ones some are free pdf.
Basically we need that resistor cause if we just used a wire from pin 2 to ground when you press the switch we would now short out our power supply. Another topic to study is called input impedance of circuits or output impedance of signal generators.