Hello to the Forum,
I introduce myself, I am Alessandro and I am a beginner in electronics. Since Christmas 2020 I have been playing with Arduino Uno, together with my son Leonardo, who is 8 years old.
I don't understand why the digital pins deliver current and potential (even 2-3 V), so much so as to turn on some LEDs and activate a piezo, even if the breadboard is not powered by anything!
The only thing that is powered is the Arduino board with the USB socket to the computer. I would have expected the USB cable power supply to power only the Arduino board and not reach the breadboard via the digital pins. And I would also have expected that the only way to power the breadboard was through the "power" pins. Where am I wrong? Thanks to who will answer me.
Greetings.
A breadboard does not need power. It's just a convenient way to connect a few components together (e.g. led and a resistor) and stick a few jumper leads in to connect it to e.g. your Arduino.
Without any buttons pressed the analog input is just floating and will pick up noise and hence a random number will be produced in analog read and so an output is triggered .
You need to pull the analog input down to 0v with a resistor ( say 10k ohm).
Why use the analog input and not use digital inputs ?
The image shows
1)
an Arduino (outer dashed line) with a processor (inner dashed line) and a single pin. The switch is a simplification of the internal electronics of a pin configured as output. The given position of the switch shows what happens when you use digitalWrite(yourPin, LOW).
2)
a breadboard with a led and resistor; the right hand dashed line
==
For current to flow, there needs to be a voltage difference over the LED. As the left side of the LED is connected to GND through the switch and the bottom of the resistor is connect to GND, there is no voltage difference and no current will flow.
If you flip the switch using digitalWrite(yourPin, HIGH), the left hand side of the LED will now have 5V from the Arduino via the switch in the processor. There is a voltage difference and hence current will flow.