Skip to main content
deleted 8 characters in body
Source Link
Dat Ha
  • 2.9k
  • 6
  • 25
  • 46

I made a circuit bellow for you. Note that the top resistor is 100 ohm and the bottom one is only 10 ohm. What I did is called a voltage divider. This way you can read voltages up to 50V. Simply connect the positive of your power source that you want to measure to the red wire and the ground of that same source to the black wire.

I also included a code that you could use:

Please notify me if any mistakes were spotted.

#define sensor A0 //defining sensor pin

float int resistor1 = 100; //you can change it if you want, just make sure you also do it on the circuit
float int resistor2 = 10;

float Vmax = (5*resistor1 + 5* resistor2)/resistor2;

void setup() {
  pinMode(sensor, INPUT); //declaring sensor as an output
  Serial.begin(9600);

  Serial.print("Do not input more then (V) : "); // print max input voltage
  Serial.print(Vmax);

  Serial.println(); //skip line
}

void loop() {
  float V = analogRead(sensor); //measuring analog values
  
  V = analogRead(sensor) * Vmax / 1024

  Serial.println(V); //printing voltage
}

enter image description here

I made a circuit bellow for you. Note that the top resistor is 100 ohm and the bottom one is only 10 ohm. What I did is called a voltage divider. This way you can read voltages up to 50V. Simply connect the positive of your power source that you want to measure to the red wire and the ground of that same source to the black wire.

I also included a code that you could use:

Please notify me if any mistakes were spotted.

#define sensor A0 //defining sensor pin

float int resistor1 = 100; //you can change it if you want, just make sure you also do it on the circuit
float int resistor2 = 10;

float Vmax = (5*resistor1 + 5* resistor2)/resistor2;

void setup() {
  pinMode(sensor, INPUT); //declaring sensor as an output
  Serial.begin(9600);

  Serial.print("Do not input more then (V) : "); // print max input voltage
  Serial.print(Vmax);

  Serial.println(); //skip line
}

void loop() {
  float V = analogRead(sensor); //measuring analog values
  
  V = analogRead(sensor) * Vmax / 1024

  Serial.println(V); //printing voltage
}

enter image description here

I made a circuit bellow for you. Note that the top resistor is 100 ohm and the bottom one is only 10 ohm. What I did is called a voltage divider. This way you can read voltages up to 50V. Simply connect the positive of your power source that you want to measure to the red wire and the ground of that same source to the black wire.

I also included a code that you could use:

Please notify me if any mistakes were spotted.

#define sensor A0 //defining sensor pin

float resistor1 = 100; //you can change it if you want, just make sure you also do it on the circuit
float resistor2 = 10;

float Vmax = (5*resistor1 + 5* resistor2)/resistor2;

void setup() {
  pinMode(sensor, INPUT); //declaring sensor as an output
  Serial.begin(9600);

  Serial.print("Do not input more then (V) : "); // print max input voltage
  Serial.print(Vmax);

  Serial.println(); //skip line
}

void loop() {
  float V = analogRead(sensor); //measuring analog values
  
  V = analogRead(sensor) * Vmax / 1024

  Serial.println(V); //printing voltage
}

enter image description here

deleted 52 characters in body
Source Link
Dat Ha
  • 2.9k
  • 6
  • 25
  • 46

I made a circuit bellow for you. Note that the top resistor is 100 ohm and the bottom one is only 10 ohm. What I did is called a voltage divider. This way you can read voltages up to 50V. Simply connect the positive of your power source that you want to measure to the red wire and the ground of that same source to the black wire.

I also included a code that you could use:

Please notify me if any mistakes were spotted.

#define sensor A0 //defining sensor pin

constfloat int resistor1 = 100; //you can change it if you want, just make sure you also do it on the circuit
constfloat int resistor2 = 10;

float Vmax = (5*resistor1 + 5* resistor2)/resistor2;

void setup() {
  pinMode(sensor, INPUT); //declaring sensor as an output
  Serial.begin(9600);

  Serial.print("Do not input more then (V) : "); // print max input voltage
  Serial.print(Vmax);

  Serial.println(); //skip line
}

void loop() {
  intfloat valV = analogRead(sensor); //measuring analog values
  
  valV = mapanalogRead(val,0,1023,0,Vmaxsensor); //transforming it into a voltage
  float V* =Vmax val/100; 1024

  Serial.println(V); //printing voltage
}

enter image description here

I made a circuit bellow for you. Note that the top resistor is 100 ohm and the bottom one is only 10 ohm. What I did is called a voltage divider. This way you can read voltages up to 50V. Simply connect the positive of your power source that you want to measure to the red wire and the ground of that same source to the black wire.

I also included a code that you could use:

Please notify me if any mistakes were spotted.

#define sensor A0 //defining sensor pin

const int resistor1 = 100; //you can change it if you want, just make sure you also do it on the circuit
const int resistor2 = 10;

float Vmax = (5*resistor1 + 5* resistor2)/resistor2;

void setup() {
  pinMode(sensor, INPUT); //declaring sensor as an output
  Serial.begin(9600);

  Serial.print("Do not input more then (V) : "); // print max input voltage
  Serial.print(Vmax);

  Serial.println(); //skip line
}

void loop() {
  int val = analogRead(sensor); //measuring analog values
  
  val = map(val,0,1023,0,Vmax); //transforming it into a voltage
  float V = val/100;

  Serial.println(V); //printing voltage
}

enter image description here

I made a circuit bellow for you. Note that the top resistor is 100 ohm and the bottom one is only 10 ohm. What I did is called a voltage divider. This way you can read voltages up to 50V. Simply connect the positive of your power source that you want to measure to the red wire and the ground of that same source to the black wire.

I also included a code that you could use:

Please notify me if any mistakes were spotted.

#define sensor A0 //defining sensor pin

float int resistor1 = 100; //you can change it if you want, just make sure you also do it on the circuit
float int resistor2 = 10;

float Vmax = (5*resistor1 + 5* resistor2)/resistor2;

void setup() {
  pinMode(sensor, INPUT); //declaring sensor as an output
  Serial.begin(9600);

  Serial.print("Do not input more then (V) : "); // print max input voltage
  Serial.print(Vmax);

  Serial.println(); //skip line
}

void loop() {
  float V = analogRead(sensor); //measuring analog values
  
  V = analogRead(sensor) * Vmax / 1024

  Serial.println(V); //printing voltage
}

enter image description here

Source Link
Dat Ha
  • 2.9k
  • 6
  • 25
  • 46

I made a circuit bellow for you. Note that the top resistor is 100 ohm and the bottom one is only 10 ohm. What I did is called a voltage divider. This way you can read voltages up to 50V. Simply connect the positive of your power source that you want to measure to the red wire and the ground of that same source to the black wire.

I also included a code that you could use:

Please notify me if any mistakes were spotted.

#define sensor A0 //defining sensor pin

const int resistor1 = 100; //you can change it if you want, just make sure you also do it on the circuit
const int resistor2 = 10;

float Vmax = (5*resistor1 + 5* resistor2)/resistor2;

void setup() {
  pinMode(sensor, INPUT); //declaring sensor as an output
  Serial.begin(9600);

  Serial.print("Do not input more then (V) : "); // print max input voltage
  Serial.print(Vmax);

  Serial.println(); //skip line
}

void loop() {
  int val = analogRead(sensor); //measuring analog values
  
  val = map(val,0,1023,0,Vmax); //transforming it into a voltage
  float V = val/100;

  Serial.println(V); //printing voltage
}

enter image description here