10 Segment Bar Graph LED Display with voltage sensor

hello, I made a very simple project that turns on the 10 Segment Bar Graph LED Display to show the percentage of my 6v 700mAh Ni-Cd AA battery pack that is connected to a voltage sensor. This is all connected to an Arduino Uno. The problem is that when I upload the sketch, the voltage sensor is giving the right voltage (I have checked with my Multimeter) but as soon as I touch the power supply wires of the voltage sensor, the 10 Segment Bar Graph LED Display turns on and the voltage sensor starts giving random values. I tried giving the voltage sensor an external power supply (another Arduino Uno) and connected the grounds but, no difference. I am learning Arduino since 6 months so feel free to correct me. Thanks

I have made a fritizing sketch

Please provide links to the data sheets of the display and "voltage sensor". And provide a circuit diagram of your project.

Ok sure
https://vimeo.com/645733154 (The wiring)
Voltage Detection Sensor Module buy online at Low Price in India - ElectronicsComp.com (Datasheet)

Hello
Test your sketch by the usage of a potentiometer instead of "voltage sensor".

Which wires are those? Where did you find wiring instructions for the module?

I think that this "sensor" is a very dangerous joke. A voltage divider does not deserve a power supply, so the third pin most probably carries the full input voltage.

It is kind of a mystery, isn't it? And a dangerous tool to leave around the shop with no instructions at all.

I do not have a potentiometer, but independently both of them work as expected

I kinda checked most of the videos and websites and all of them showed the same wiring to the same pin
Referred to the code from here: Arduino code and video for Voltage Sensor Module | Robojax

@DrDiettrich Can you please explain it in simple terms, I didn't understand

They're Female to Male Jumper wires

Here's the code as well

const int voltageSensor = A0;
int offset = -40;
const int led1 = 11;
const int led2 = 10;
const int led3 = 9;
const int led4 = 8;
const int led5 = 7;
const int led6 = 2;
const int led7 = 4;
const int led8 = 5;
const int led9 = 3;
const int led10 = 6;

void setup()
{

  Serial.begin(9600);
}

void loop()

{

  int volt = analogRead(A0);
  double voltage = map(volt, 0, 1023, 0, 2500) + offset;
  voltage /= 100;
  Serial.println(voltage);


  if (voltage < 0)
  {
    analogWrite(led1, 0);
    analogWrite(led2, 0);
    analogWrite(led3, 0);
    analogWrite(led4, 0);
    analogWrite(led5, 0);
    analogWrite(led6, 0);
    analogWrite(led7, 0);
    analogWrite(led8, 0);
    analogWrite(led9, 0);
    analogWrite(led10, 0);
  }
  if (voltage < 0.6)
  {
    analogWrite(led1, 255);
  }
  if (voltage > 0.7 && voltage < 1.2)
  {
    analogWrite(led1, 255);
    analogWrite(led2, 255);
  }
  if (voltage > 1.2 && voltage < 1.8)
  {
    analogWrite(led1, 255);
    analogWrite(led2, 255);
    analogWrite(led3, 255);
  }
  if (voltage > 1.8 && voltage < 2.4)
  {
    analogWrite(led1, 255);
    analogWrite(led2, 255);
    analogWrite(led3, 255);
    analogWrite(led4, 255);
  }
  if (voltage > 2.4 && voltage < 3)
  {
    analogWrite(led1, 255);
    analogWrite(led2, 255);
    analogWrite(led3, 255);
    analogWrite(led4, 255);
    analogWrite(led5, 255);
  }
  if (voltage > 3 && voltage < 3.6)
  {
    analogWrite(led1, 255);
    analogWrite(led2, 255);
    analogWrite(led3, 255);
    analogWrite(led4, 255);
    analogWrite(led5, 255);
    analogWrite(led6, 255);
  }
  if (voltage > 3.6 && voltage < 4.2)
  {
    analogWrite(led1, 255);
    analogWrite(led2, 255);
    analogWrite(led3, 255);
    analogWrite(led4, 255);
    analogWrite(led5, 255);
    analogWrite(led6, 255);
    analogWrite(led7, 255);
  }
  if (voltage > 4.2 && voltage < 4.8)
  {
    analogWrite(led1, 255);
    analogWrite(led2, 255);
    analogWrite(led3, 255);
    analogWrite(led4, 255);
    analogWrite(led5, 255);
    analogWrite(led6, 255);
    analogWrite(led7, 255);
    analogWrite(led8, 255);
    analogWrite(led9, 0);
    analogWrite(led10, 0);
  }
  if (voltage > 4.8 && voltage < 5.4)
  {
    analogWrite(led1, 255);
    analogWrite(led2, 255);
    analogWrite(led3, 255);
    analogWrite(led4, 255);
    analogWrite(led5, 255);
    analogWrite(led6, 255);
    analogWrite(led7, 255);
    analogWrite(led8, 255);
    analogWrite(led9, 255);
    analogWrite(led10, 0);
  }
  if (voltage > 6)
  {
    analogWrite(led1, 255);
    analogWrite(led2, 255);
    analogWrite(led3, 255);
    analogWrite(led4, 255);
    analogWrite(led5, 255);
    analogWrite(led6, 255);
    analogWrite(led7, 255);
    analogWrite(led8, 255);
    analogWrite(led9, 255);
    analogWrite(led10, 255);
  }

}

Are you happy with your sketch?

Sure I am, this is just a prototype of the project I make going to make

Hi, @samit_paarth
Welcome to the forum.

Can you please post a circuit diagram and some pictures of your project please.
What power supply is your Uno running on?
Please include it in your schematic.

Have you tried putting a 0.1uF capacitor between gnd and the analog input A0.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Sure Tom

the Arduino Uno Is running on a USB connected to my computer
and I have already sent a video in the previous replies

Hi,
If you look at the video you posted in post#9, the + terminal of the module is not connected, yet you do with an orange wire.
Can I suggest you remove the orange wire completely.

PLEASE draw a circuit of your project for us, reverse engineer your project.
A hand drawn circuit will be great.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

I have made a fritizing sketch

Hi,
Do you have series current limit resistors on each of those LEDS?
Fritzy is not a circuit diagram.
Please draw one?

Have you removed the orange wire I pointed out in post #19?

Tom... :smiley: :+1: :coffee: :australia: