Arduino Uno grounding/wiring incorrectly?


As shown above, for some reasons, in-built LED is activated and fluctuating between 0 and 1 whenever I touched the table. The table is made out of glass like in the picture. Not only that, everytime I touch the board or even just move it slightly, it registers a switch on LED. I suspect that it's grounding problem. I am just using the button sketch from example.

Your input pin is probably floating if the button is not pressed. So it picks up noise from the environment and that is what your code reacts on.

I do not know what the button sketch example is. You should be more accurate with that and preferable post the sketch here (don't forget code tags as described in How to get the best out of this forum).

/*
  Button

  Turns on and off a light emitting diode(LED) connected to digital pin 13,
  when pressing a pushbutton attached to pin 2.

  The circuit:
  - LED attached from pin 13 to ground through 220 ohm resistor
  - pushbutton attached to pin 2 from +5V
  - 10K resistor attached to pin 2 from ground

  - Note: on most Arduinos there is already an LED on the board
    attached to pin 13.

  created 2005
  by DojoDave <http://www.0j0.org>
  modified 30 Aug 2011
  by Tom Igoe

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button
*/

// constants won't change. They're used here to set pin numbers:
const int buttonPin = 2;  // the number of the pushbutton pin
const int ledPin = 13;    // the number of the LED pin

// variables will change:
int buttonState = 0;  // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
  Serial.begin(9600);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  } else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
  Serial.println(buttonState);
}

This is what I refered as button sketch. It's the standard example I pulled out from arduino IDE, pretty weird if someone just straight up claim they do not know it when they lurk in the arduino forum.

The pins aren't connected to anything. Pretty sure the noise shouldn't be able to raise voltages enough for the pin to read anything, but I might be wrong. I tried to wire them up according to the sketch, anyway, but it returns fluctuating output even when I did not touch the button at all.

Processing: WhatsApp Image 2024-06-28 at 15.51.09_60cc67f3.jpg…

Processing: WhatsApp Image 2024-06-28 at 15.51.09_bf4d4cde.jpg…

That says it all

There is nothing keeping the input pin in a known state and it is, therefore. possible for it to be affected by local electric fields

As an experiment use INPUT_PULLUP in pinMode() for the input pin to activate the built in pullup resistor. Does the operation of the project change in any way ?


these are the picture of the board and the wires and also the sketch.I don't think it's the problem of noise input. I have used this arduino for a few projects, is it possible that it is broken?

I believe so. The Tx and RX lights should NOT be lit

it's not broken, you left the pin floating, you should set the pin mode to INPUT_PULLUP, this time the pin isn't floating to pick up random noise, or the capacitively coupled wall power, but this time the button should be connected to GND, and the pin is now LOW when the button is pressed, and HIGH otherwise.

I don't consider it weird :rofl:

  1. I might have been using a system without the IDE installed.
  2. That was not the case, I did check file/examples/basics and did not immediately see something that would reflect a button and a LED. The DigitalReadSerial was the closest and I did open that. I was not prepared to go through every single example.
  3. The last time that I looked at the built-in examples was probably 7 years ago. My memory is not that great :cry:

wait! isn't the RX led the Arduino's receiver light?
if so, that should NOT be on!
and why isn't the TX light on, by the looks of the code, it SHOULD be on, well to our eyes.

See post #6

See post #6 please

I saw you said, however on the image he sent, the TX led was not lit, only the ON, RX, and L leds were lit.

This worked perfectly. But I don't think it solved the fluctuating input read when input pullup isn't used. I don't know how input pin picks up voltages when it is connected to ground via 10k resistor when it's not connected to voltage positive.

Try this:

Regarding to this I am not quite sure, but 2 leds always lit when arduino is on, but I never notice which leds. Which one should normally lit anyways?

I'm glad this works for you!
have fun with your Arduino!

the ON led, it should always be lit when your Arduino is on, and your L led when you either turned it on, or you're not using it.

How much fluctuation?
An input pin will always pick up noise unless it's a dead short to ground or Vcc

@arduinot
Look carefully at that breadboard. The power rails you're assuming are continuous down both sides have a gap. Half your wiring is on each side of the gap, so it's not surprising the effects are unexpected. Move the whole setup to one side of that gap or the other.
It's been at least a month since we've seen a beginner tricked by that little 'feature'.

2 Likes

Good catch!