Loosing Voltage on digital pin

Hi all, I'm new in Arduino and electronics. I'M working on a Quiz_buzzer projet with 2 team and 10 player in total.

I got the Arduino Mega and I use Pin 22 to 53 for my project.

I use 1 push button and 1 LED for each player, a ready LED and 2 Teams LED.

The problem I got is the arduino drain the voltage on 1 digital pin down to 2.3 volts that make trig the LOW states of the pin and start the buzzer for that PIN. I try to push 5v in paralelle with a 4.6k ohm into the PIN but the voltage keep going down on that pin.

If I remove that pin on my code, the voltage go down on the next pin etc.

Does this is a coding issus or hardware issus..

Thank you.

Eric

Does this is a coding issus or hardware issus..

Since we cannot see your code nor can we see how everything is wired, I can't see how we can, intelligently, answer your question.

I try to push 5v in paralelle with a 4.6k ohm into the PIN

What does that mean?

Please post a schematic of your wiring. Show all components, thier values and power supplies. Hand drawn, photographed and posted is more acceptable than a Fritz diagram. How to post an image.

Post your code. Read the how to use this forum-please read sticky to see how to properly post code and some advice on how to ask an effective question. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

There is the code with annotation;

For the 5v there is the shematic

+5v ------ 4,6 koHm resistor ---- Digital PIN X
|_____ push button open ------- GRND

buzzer.ino (10.2 KB)

If you use pinMode(pin, INPUT_PULLUP); you will save yourself the trouble of adding all the external pull-up resistors.

When you have a problem like you describe you should write a short 10 or 20 line program to figure out what is happening.

...R

If you post your code as described in the how to you this forum post (linked in reply #1) more people will see it. It is a time consuming pain for me to download code to view on my tablet and then I have to delete it.

Robin2:
If you use pinMode(pin, INPUT_PULLUP); you will save yourself the trouble of adding all the external pull-up resistors.

When you have a problem like you describe you should write a short 10 or 20 line program to figure out what is happening.

...R

Hi, I wasn't use external pullup resistor before, someone tell me to test that if it's fix the issus but it still there.

Sorry, there is the code

  int x=1;// take int value as 1

void setup() {
 pinMode(52,INPUT_PULLUP);   //P A1
 pinMode(50,INPUT_PULLUP);   //P A2
 pinMode(48,INPUT_PULLUP);   //P A3
 pinMode(46,INPUT_PULLUP);   //P A4
 pinMode(44,INPUT_PULLUP);   //P A5
 pinMode(42,INPUT_PULLUP);   //P B1
 pinMode(40,INPUT_PULLUP);   //P B2   
 pinMode(38,INPUT_PULLUP);   //P B3
 pinMode(36,INPUT_PULLUP);   //P B4   
 pinMode(34,INPUT_PULLUP);   //P B5
 pinMode(53,OUTPUT);         //P A1
 pinMode(51,OUTPUT);         //P A2
 pinMode(49,OUTPUT);         //P A3
 pinMode(47,OUTPUT);         //P A4
 pinMode(45,OUTPUT);         //P A5
 pinMode(43,OUTPUT);         //P B1
 pinMode(41,OUTPUT);         //P B2
 pinMode(39,OUTPUT);         //P B3
 pinMode(37,OUTPUT);         //P B4
 pinMode(35,OUTPUT);         //P B5
 pinMode(33,OUTPUT);  // buzzer
 pinMode(32,OUTPUT);  // TeamGreen
 pinMode(30,OUTPUT);  // TeamRed
 pinMode(31,OUTPUT);  // ReadyLED
  
 // set initially LED to Ready
digitalWrite(53,LOW);         //P A1
digitalWrite(51,LOW);         //P A2
digitalWrite(49,LOW);         //P A3
digitalWrite(47,LOW);         //P A4
digitalWrite(45,LOW);         //P A5
digitalWrite(43,LOW);         //P B1
digitalWrite(41,LOW);         //P B2
digitalWrite(39,LOW);         //P B3
digitalWrite(37,LOW);         //P B4
digitalWrite(35,LOW);         //P B5
digitalWrite(33,LOW);  // buzzer
digitalWrite(32,LOW);  // Team Green
digitalWrite(30,LOW);  // Team Red
digitalWrite(31,HIGH);  // Ready LED
                   
      }

void loop() 
{

  int a=digitalRead(52);   // reading pin values for 10 buttons
    int b=digitalRead(50);
      int c=digitalRead(48);
        int d=digitalRead(46);
          int e=digitalRead(44);
            int f=digitalRead(42);
             int g=digitalRead(40);
               int h=digitalRead(38);
                 int i=digitalRead(36);
                   int j=digitalRead(34);
             

if(a==LOW)  //if 1 player press button
 {       if(x==1)    // check if x is 1 if yes then execute the code
     {
digitalWrite(53,HIGH);        //P A1
digitalWrite(51,LOW);         //P A2
digitalWrite(49,LOW);         //P A3
digitalWrite(47,LOW);         //P A4
digitalWrite(45,LOW);         //P A5
digitalWrite(43,LOW);         //P B1
digitalWrite(41,LOW);         //P B2
digitalWrite(39,LOW);         //P B3
digitalWrite(37,LOW);         //P B4
digitalWrite(35,LOW);         //P B5
digitalWrite(33,HIGH);  // buzzer
digitalWrite(32,HIGH);  // TeamGreen
digitalWrite(30,LOW);  // TeamRed
digitalWrite(31,LOW);  // ReadyLED
     x++;                     //increment x
      }
 }
 else if(b==LOW) //if player 2 press button
 { 
  if(x==1) // check if x is 1 if yes then execute the code
     {
digitalWrite(53,LOW);        //P A1
digitalWrite(51,HIGH);         //P A2
digitalWrite(49,LOW);         //P A3
digitalWrite(47,LOW);         //P A4
digitalWrite(45,LOW);         //P A5
digitalWrite(43,LOW);         //P B1
digitalWrite(41,LOW);         //P B2
digitalWrite(39,LOW);         //P B3
digitalWrite(37,LOW);         //P B4
digitalWrite(35,LOW);         //P B5
digitalWrite(33,HIGH);  // buzzer
digitalWrite(32,HIGH);  // TeamGreen
digitalWrite(30,LOW);  // TeamRed
digitalWrite(31,LOW);  // ReadyLED
          x++;
      }
 }
else if(c==LOW) //if player 3 press button
 { 
        if(x==1) // check if x is 1 if yes then execute the code
       { 
digitalWrite(53,LOW);        //P A1
digitalWrite(51,LOW);         //P A2
digitalWrite(49,HIGH);         //P A3
digitalWrite(47,LOW);         //P A4
digitalWrite(45,LOW);         //P A5
digitalWrite(43,LOW);         //P B1
digitalWrite(41,LOW);         //P B2
digitalWrite(39,LOW);         //P B3
digitalWrite(37,LOW);         //P B4
digitalWrite(35,LOW);         //P B5
digitalWrite(33,HIGH);  // buzzer
digitalWrite(32,HIGH);  // TeamGreen
digitalWrite(30,LOW);  // TeamRed
digitalWrite(31,LOW);  // ReadyLED
      x++;
       }
 }
else if(d==LOW)   //if player 4 press button
 {      if(x==1) // check if x is 1 if yes then execute the code
        {   
digitalWrite(53,LOW);        //P A1
digitalWrite(51,LOW);         //P A2
digitalWrite(49,LOW);         //P A3
digitalWrite(47,HIGH);         //P A4
digitalWrite(45,LOW);         //P A5
digitalWrite(43,LOW);         //P B1
digitalWrite(41,LOW);         //P B2
digitalWrite(39,LOW);         //P B3
digitalWrite(37,LOW);         //P B4
digitalWrite(35,LOW);         //P B5
digitalWrite(33,HIGH);  // buzzer
digitalWrite(32,HIGH);  // TeamGreen
digitalWrite(30,LOW);  // TeamRed
digitalWrite(31,LOW);  // ReadyLED
      x++;
       }
 }
else if(e==LOW)  //if player 5 press button
 { 
      if(x==1) // check if x is 1 if yes then execute the code
      { 
digitalWrite(53,LOW);        //P A1
digitalWrite(51,LOW);         //P A2
digitalWrite(49,LOW);         //P A3
digitalWrite(47,LOW);         //P A4
digitalWrite(45,HIGH);         //P A5
digitalWrite(43,LOW);         //P B1
digitalWrite(41,LOW);         //P B2
digitalWrite(39,LOW);         //P B3
digitalWrite(37,LOW);         //P B4
digitalWrite(35,LOW);         //P B5
digitalWrite(33,HIGH);  // buzzer
digitalWrite(32,HIGH);  // TeamGreen
digitalWrite(30,LOW);  // TeamRed
digitalWrite(31,LOW);  // ReadyLED
   x++;
     }
 }
else if(f==LOW)  //if player 6 press button
 {    if(x==1) // check if x is 1 if yes then execute the code
     {
digitalWrite(53,LOW);        //P A1
digitalWrite(51,LOW);         //P A2
digitalWrite(49,LOW);         //P A3
digitalWrite(47,LOW);         //P A4
digitalWrite(45,LOW);         //P A5
digitalWrite(43,HIGH);         //P B1
digitalWrite(41,LOW);         //P B2
digitalWrite(39,LOW);         //P B3
digitalWrite(37,LOW);         //P B4
digitalWrite(35,LOW);         //P B5
digitalWrite(33,HIGH);  // buzzer
digitalWrite(32,LOW);  // TeamGreen
digitalWrite(30,HIGH);  // TeamRed
digitalWrite(31,LOW);  // ReadyLED
       x++;
       }
 }
else if(g==LOW)  //if player 7 press button
 {     if(x==1) // check if x is 1 if yes then execute the code
     {
digitalWrite(53,LOW);        //P A1
digitalWrite(51,LOW);         //P A2
digitalWrite(49,LOW);         //P A3
digitalWrite(47,LOW);         //P A4
digitalWrite(45,LOW);         //P A5
digitalWrite(43,LOW);         //P B1
digitalWrite(41,HIGH);         //P B2
digitalWrite(39,LOW);         //P B3
digitalWrite(37,LOW);         //P B4
digitalWrite(35,LOW);         //P B5
digitalWrite(33,HIGH);  // buzzer
digitalWrite(32,LOW);  // TeamGreen
digitalWrite(30,HIGH);  // TeamRed
digitalWrite(31,LOW);  // ReadyLED
       x++;
      }
 }

else if(h==LOW)  //if player 8 press button
 {      if(x==1) // check if x is 1 if yes then execute the code
      { 
digitalWrite(53,LOW);        //P A1
digitalWrite(51,LOW);         //P A2
digitalWrite(49,LOW);         //P A3
digitalWrite(47,LOW);         //P A4
digitalWrite(45,LOW);         //P A5
digitalWrite(43,LOW);         //P B1
digitalWrite(41,LOW);         //P B2
digitalWrite(39,HIGH);         //P B3
digitalWrite(37,LOW);         //P B4
digitalWrite(35,LOW);         //P B5
digitalWrite(33,HIGH);  // buzzer
digitalWrite(32,LOW);  // TeamGreen
digitalWrite(30,HIGH);  // TeamRed
digitalWrite(31,LOW);  // ReadyLED
   x++;
       }
 }
 else if(i==LOW)  //if player 9 press button
 {      if(x==1) // check if x is 1 if yes then execute the code
      { 
digitalWrite(53,LOW);        //P A1
digitalWrite(51,LOW);         //P A2
digitalWrite(49,LOW);         //P A3
digitalWrite(47,LOW);         //P A4
digitalWrite(45,LOW);         //P A5
digitalWrite(43,LOW);         //P B1
digitalWrite(41,LOW);         //P B2
digitalWrite(39,LOW);         //P B3
digitalWrite(37,HIGH);         //P B4
digitalWrite(35,LOW);         //P B5
digitalWrite(33,HIGH);  // buzzer
digitalWrite(32,LOW);  // TeamGreen
digitalWrite(30,HIGH);  // TeamRed
digitalWrite(31,LOW);  // ReadyLED
   x++;
       }
 }
 else if(j==LOW)  //if player 10 press button
 {      if(x==1) // check if x is 1 if yes then execute the code
      { 
digitalWrite(53,LOW);        //P A1
digitalWrite(51,LOW);         //P A2
digitalWrite(49,LOW);         //P A3
digitalWrite(47,LOW);         //P A4
digitalWrite(45,LOW);         //P A5
digitalWrite(43,LOW);         //P B1
digitalWrite(41,LOW);         //P B2
digitalWrite(39,LOW);         //P B3
digitalWrite(37,LOW);         //P B4
digitalWrite(35,HIGH);         //P B5
digitalWrite(33,HIGH);  // buzzer
digitalWrite(32,LOW);  // TeamGreen
digitalWrite(30,HIGH);  // TeamRed
digitalWrite(31,LOW);  // ReadyLED
   x++;
       }
 }
}

[/code]

When you find yourself writing repetitive code like this it is time to learn about arrays and FOR loops

pinMode(52,INPUT_PULLUP);   //P A1
 pinMode(50,INPUT_PULLUP);   //P A2
 pinMode(48,INPUT_PULLUP);   //P A3
 pinMode(46,INPUT_PULLUP);   //P A4
 pinMode(44,INPUT_PULLUP);   //P A5
 pinMode(42,INPUT_PULLUP);   //P B1
 pinMode(40,INPUT_PULLUP);   //P B2   
 pinMode(38,INPUT_PULLUP);   //P B3
 pinMode(36,INPUT_PULLUP);   //P B4   
 pinMode(34,INPUT_PULLUP);   //P B5

Please make a simple pencil drawing showing exactly how an input pin and its corresponding output pin is wired and post a photo of the drawing. See this Simple Image Posting Guide

...R

There is the shematic. I reduce my code to fit 5 player on Arduino UNO. Actualy my project ar build on Arduino Mega PIN 22 to 53.

LED resistor 220Ohm
Pushbutton Resistor 4.6KOhm

  int x=1;// take int value as 1

void setup() {
 pinMode(6,INPUT_PULLUP);   //Player Green 1
 pinMode(5,INPUT_PULLUP);   //Player Green 2
 pinMode(4,INPUT_PULLUP);   //Player Green 3
 pinMode(3,INPUT_PULLUP);   //Player Green 4
 pinMode(2,INPUT_PULLUP);   //Player Green 5
 pinMode(7,OUTPUT);         //Player Green 1
 pinMode(8,OUTPUT);         //Player Green 2
 pinMode(9,OUTPUT);         //Player Green 3
 pinMode(10,OUTPUT);         //Player Green 4
 pinMode(11,OUTPUT);         //Player Green 5
 pinMode(13,OUTPUT);  // output for buzzer
 pinMode(12,OUTPUT);  // output Ready LED
  
 // set initially LED to Ready
digitalWrite(7,LOW);         //Player Green 1
digitalWrite(8,LOW);         //Player Green 2
digitalWrite(9,LOW);         //Player Green 3
digitalWrite(10,LOW);         //Player Green 4
digitalWrite(11,LOW);         //Player Green 5
digitalWrite(13,LOW);  // output for buzzer
digitalWrite(12,HIGH);  // output Ready LED
                   
      }

void loop() 
{

  int a=digitalRead(6);   // reading pin values for 10 buttons
    int b=digitalRead(5);
      int c=digitalRead(4);
        int d=digitalRead(3);
          int e=digitalRead(2);
             

if(a==LOW)  //if 1 player press button
 {       if(x==1)    // check if x is 1 if yes then execute the code
     {
digitalWrite(7,HIGH);        //Player Green 1
digitalWrite(8,LOW);         //Player Green 2
digitalWrite(9,LOW);         //Player Green 3
digitalWrite(10,LOW);         //Player Green 4
digitalWrite(11,LOW);         //Player Green 5
digitalWrite(13,HIGH);  // output for buzzer
digitalWrite(12,LOW);  // output Ready LED
     x++;                     //increment x
      }
 }
 else if(b==LOW) //if player 2 press button
 { 
  if(x==1) // check if x is 1 if yes then execute the code
     {
digitalWrite(7,LOW);        //Player Green 1
digitalWrite(8,HIGH);         //Player Green 2
digitalWrite(9,LOW);         //Player Green 3
digitalWrite(10,LOW);         //Player Green 4
digitalWrite(11,LOW);         //Player Green 5
digitalWrite(13,HIGH);  // output for buzzer
digitalWrite(12,LOW);  // output Ready LED
          x++;
      }
 }
else if(c==LOW) //if player 3 press button
 { 
        if(x==1) // check if x is 1 if yes then execute the code
       { 
digitalWrite(7,LOW);        //Player Green 1
digitalWrite(8,LOW);         //Player Green 2
digitalWrite(9,HIGH);         //Player Green 3
digitalWrite(10,LOW);         //Player Green 4
digitalWrite(11,LOW);         //Player Green 5
digitalWrite(13,HIGH);  // output for buzzer
digitalWrite(12,LOW);  // output Ready LED
      x++;
       }
 }
else if(d==LOW)   //if player 4 press button
 {      if(x==1) // check if x is 1 if yes then execute the code
        {   
digitalWrite(7,LOW);        //Player Green 1
digitalWrite(8,LOW);         //Player Green 2
digitalWrite(9,LOW);         //Player Green 3
digitalWrite(10,HIGH);         //Player Green 4
digitalWrite(11,LOW);         //Player Green 5
digitalWrite(13,HIGH);  // output for buzzer
digitalWrite(12,LOW);  // output Ready LED
      x++;
       }
 }
else if(e==LOW)  //if player 5 press button
 { 
      if(x==1) // check if x is 1 if yes then execute the code
      { 
digitalWrite(7,LOW);        //Player Green 1
digitalWrite(8,LOW);         //Player Green 2
digitalWrite(9,LOW);         //Player Green 3
digitalWrite(10,LOW);         //Player Green 4
digitalWrite(11,HIGH);         //Player Green 5
digitalWrite(13,HIGH);  // output for buzzer
digitalWrite(12,LOW);  // output Ready LED
   x++;
       }
 }

}

I hope someone can help you, but I don’t even try to follow Fritzy diagrams.

A schematic is not a wiring diagram. Similar, but the purpose is different.

Image from Reply #8 so we don't have to download it. See this Simple Image Posting Guide

...R

@JesterQc, in Reply #7 I specifically asked you to make a pencil drawing. Fritzing diagrams are useless - they far too easy to misunderstand.

...R

Another thread proving Friztings are a complete waste of everyone’s time, the OP’s included.

Obvious pin assignments in the OP’s program indicate a Mega with an Uno in the Fritzing.

Please try again, this time with a pencil and paper.

Robin2:
When you find yourself writing repetitive code like this it is time to learn about arrays and FOR loops

Karma for you, that's the most helpful suggestion in the thread!

Jester, arrays are arrangements of variables under one name with each addressed by number.

All of your led pin numbers could be stored in a 1D array of bytes

const byte ledPin[] = { 53,51,49,47,45,43,41,39,37,35,33,32,30,31 }; // makes and fills ledPin constant array
// ledPin[0] is 53, ledPin[5] is 43

Except for the index, the code to process one is the code to process them all or just the ones you want.

Save your poor typing fingers and eyes straining over so much code just to do simple things.
Get onto arrays and loops!

What I would do...
I would use WS2812 string leds for the leds. Only needs one data pin for the string.
I would use 6 pins for a 5x2 matrix with diode per button allowing many buttons pressed at once.
Those 6 pins can be set or read together very fast if they're all on the same port of even an Uno.

And you have a buzzer. One more pin makes 8.

Here is one way to do it with arrays and loops:

const byte ButtonInputPins[10] = {52, 50, 48, 46, 44, 42, 40, 38, 36, 34};
const byte WinnerLightPins[10] = {53, 51, 49, 47, 45, 43, 41, 39, 37, 35};


const byte BuzzerPin = 33; // buzzer
const byte TeamGreenPin = 32; // TeamGreen LED pin
const byte TeamRedPin = 30; // TeamRed LED pin
const byte ReadyLEDPin = 31; // ReadyLED


void setup() 
{
  for (int player = 0; player < 10; player++)
  {
    pinMode(ButtonInputPins[player], INPUT_PULLUP);
    digitalWrite(WinnerLightPins[player], LOW);
    pinMode(WinnerLightPins[player], OUTPUT);
  }

  pinMode(BuzzerPin, OUTPUT); // buzzer
  pinMode(TeamGreenPin, OUTPUT); // TeamGreen
  pinMode(TeamRedPin, OUTPUT); // TeamRed
  pinMode(ReadyLEDPin, OUTPUT); // ReadyLED

  digitalWrite(BuzzerPin, LOW); // buzzer
  digitalWrite(TeamGreenPin, LOW); // Team Green
  digitalWrite(TeamRedPin, LOW); // Team Red
  digitalWrite(ReadyLEDPin, HIGH); // Ready LED
}


void loop()
{
  for (int player = 0; player < 10; player++)
  {
    if (digitalRead(ButtonInputPins[player]) == LOW) // PRESSED
    {
      digitalWrite(WinnerLightPins[player], HIGH);  // Light the winner's light
      digitalWrite(BuzzerPin, HIGH); // buzzer
      if (player < 5)
        digitalWrite(TeamGreenPin, HIGH); // TeamGreen
      else
        digitalWrite(TeamRedPin, HIGH); // TeamGreen
      digitalWrite(ReadyLEDPin, LOW); // ReadyLED


      delay(10000); // Wait 10 seconds befor starting again


      // Reset
      digitalWrite(WinnerLightPins[player], LOW);
      digitalWrite(BuzzerPin, LOW);    // buzzer
      digitalWrite(TeamGreenPin, LOW); // TeamGreen
      digitalWrite(TeamRedPin, LOW); // TeamGreen
      digitalWrite(ReadyLEDPin, HIGH); // ReadyLED


      break;  // Skip the rest of the loop since we found a winner
    }
  }
}

JesterQc:
The problem I got is the arduino drain the voltage on 1 digital pin down to 2.3 volts that make trig the LOW states of the pin and start the buzzer for that PIN. I try to push 5v in paralelle with a 4.6k ohm into the PIN but the voltage keep going down on that pin.

Without the button on pin2 being pressed;

  • Measure the voltage between gnd and the input pin 2.

With the button on Pin2 being pressed;

  • Measure the voltage between gnd and the input pin 2.

Thanks... Tom... :slight_smile:

johnwasser:
Here is one way to do it with arrays and loops:

const byte ButtonInputPins[10] = {52, 50, 48, 46, 44, 42, 40, 38, 36, 34};

const byte WinnerLightPins[10] = {53, 51, 49, 47, 45, 43, 41, 39, 37, 35};

const byte BuzzerPin = 33; // buzzer
const byte TeamGreenPin = 32; // TeamGreen LED pin
const byte TeamRedPin = 30; // TeamRed LED pin
const byte ReadyLEDPin = 31; // ReadyLED

void setup()
{
  for (int player = 0; player < 10; player++)
  {
    pinMode(ButtonInputPins[player], INPUT_PULLUP);
    digitalWrite(WinnerLightPins[player], LOW);
    pinMode(WinnerLightPins[player], OUTPUT);
  }

pinMode(BuzzerPin, OUTPUT); // buzzer
  pinMode(TeamGreenPin, OUTPUT); // TeamGreen
  pinMode(TeamRedPin, OUTPUT); // TeamRed
  pinMode(ReadyLEDPin, OUTPUT); // ReadyLED

digitalWrite(BuzzerPin, LOW); // buzzer
  digitalWrite(TeamGreenPin, LOW); // Team Green
  digitalWrite(TeamRedPin, LOW); // Team Red
  digitalWrite(ReadyLEDPin, HIGH); // Ready LED
}

void loop()
{
  for (int player = 0; player < 10; player++)
  {
    if (digitalRead(ButtonInputPins[player]) == LOW) // PRESSED
    {
      digitalWrite(WinnerLightPins[player], HIGH);  // Light the winner's light
      digitalWrite(BuzzerPin, HIGH); // buzzer
      if (player < 5)
        digitalWrite(TeamGreenPin, HIGH); // TeamGreen
      else
        digitalWrite(TeamRedPin, HIGH); // TeamGreen
      digitalWrite(ReadyLEDPin, LOW); // ReadyLED

delay(10000); // Wait 10 seconds befor starting again

// Reset
      digitalWrite(WinnerLightPins[player], LOW);
      digitalWrite(BuzzerPin, LOW);    // buzzer
      digitalWrite(TeamGreenPin, LOW); // TeamGreen
      digitalWrite(TeamRedPin, LOW); // TeamGreen
      digitalWrite(ReadyLEDPin, HIGH); // ReadyLED

break;  // Skip the rest of the loop since we found a winner
    }
  }
}

Thank you GoForSmoke and JohnWasser. That's a lot of information to process for my newbe brain. I will try this right a way.

Thank you very much.

For a Fritzing that diagram was not even too bad (no multiple lines crossing or overlapping as is common).

But indeed, why Uno, no Mega there? It's not a representation of YOUR setup.

Why is that one button connected to the RESET pin in your image? There are extremely few reasons to do so, and even most of those mean you're doing something else wrong.

Are you sure that buzzer doesn't draw more than 20 mA from the pin? More than that and you're overloading it.

Piezos don't conduct.

Ah, missed that it's a piezo.