I want to detect the simple DC voltage using arduino Mega .Using arduino i read the voltage using analog pin (A0) that the code working fine.
But my actually voltage 2.8 v and but I should increase my voltage .5v they should not detect the voltage
So how to detect the changing d c voltage using arduino Use code tags to format code for the forum
float value= A0;
const float refer_voltage = 2.8;
void setup()
{
pinMode(value, INPUT);
Serial.begin(9600);
}
void loop()
{
int data = analogRead(value);
float voltage = data*(refer_voltage/1023.0);
Serial.println(voltage,2);
delay(1000);
}
that refer_volatge is coming from DC supply
this is my code please suggest me some reference
Can I try rewording this toyew?
You have a Mega with an input voltage connected to A0.
your code indicates you have a reference voltage of 2.8V
but you will be using the "default" which is Vcc.
The lowest voltage you can use to power the Mega is 5V.
The power pins are as follows:
Vin. The input voltage to the board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin.
5V. This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.
If you are connecting ANYTHING to the AREF pin you will most likely damage your board.
Can you provide a schematic please so we can see how you have connected the board up
The reason I ask is because you both posted very similar questions within a matter of hours of each other. Here is the other question:
If you are working together on a project I would combine the two topics so that the time of the volunteer helpers here on the forum isn't wasted through duplicated efforts.