why the digital pins deliver current to the breadboard?

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.

Alessandro

Please post your code and your schematic.

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.

TheMemberFormerlyKnownAsAWOL:
Please post your code and your schematic.

int notes[]={30,440,1850,4100};
const int switchPin=6;
int led=9;
long interval=1000;
unsigned long previousTime = 0;
int switchState=0;
int prevSwitchState=0;
void setup() {
Serial.begin(9600);
for(int x=9;x<13;x++){
pinMode(x,OUTPUT);
}
pinMode(switchPin, INPUT);
}
void loop() {
int keyVal=analogRead(A3);
Serial.println(keyVal);
if(keyVal == 1023){
  tone(3, notes[0]);
  }
else if(keyVal >=900 && keyVal <=1000){
  tone(3, notes[1]);
  }
else if(keyVal >=800 && keyVal <=900){
  tone(3, notes[2]);
  }
else if(keyVal >=700 && keyVal <=800){
  tone(3, notes[3]);
  }
else {
    noTone(3);
    }
    unsigned long currentTime=millis();
if(currentTime - previousTime> interval){
  previousTime=currentTime;
  digitalWrite(led, HIGH);
  led++;
  if(led==12){
   }
  }
  switchState=digitalRead(switchPin);
  if (switchState != prevSwitchState){
    for (int x=9;x<13;x++){
      digitalWrite(x, LOW);
            }
            led=9;
            previousTime= currentTime;
                }
prevSwitchState=switchState;
  }

project 16.pdf (1.72 MB)

You will have to put current limiting resistors in series with your leds.

Next time, please attach a jpg or png instead of pdf so we don't have to download. They will automatically be inserted in your post.

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 ?

Maybe below makes clear how the current flows

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.

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