Detecting Voltages on the arduino?

Hello i was wondering something about Detecting voltages on the arduino uno. My project i would like to detect the minimum voltage for the arduino problem is the source of the voltage can be as low as half of a volt. All i wanted to do is light up a led that's all. Is it possible to detect a low voltage of a half of a volt?

Joseph

Yes it can easily detect half a volt. Lots of examples on the net. See for example: http://www.arduino.cc/en/Tutorial/AnalogInput

Russell.

You mean you want to light up an LED it there is halve a volt? Than a Arduino is overkill. Just use a comperator and a set potentiometer.

Hello thank you for the reply back what I'm trying to do is max voltage is 1v it can put out but it can be as low as a half of a volt what I like to do is light up a led or maybe pwm the led at a later time. So if it's like half of a volt can make the led half the brightness and if at .75vcan be 3/4 way brightness and if at a full 1 volt then 100% of the. Brightness of the led. But for now just testing a off and on process when voltage is there.

To do it in 3 steps:

void setup() {
  const byte LedPin = 10;
  const byte VoltageIn = A0;
  
  pinMode(LedPin, OUTPUT);
  pinMode(VoltageIn, INPUT);

}

void loop() {
  int analogVal = analogRead(VoltageIn);
  
  //205 for 1V
  if(analogVal > 205){
    analogWrite(LedPin, 255);
  }
  //153 for 0.75V
  else if(analogVal > 153){
    analogWrite(LedPin, 192);
  }
  //102 for 0.5V
  else if(analogVal > 102){
    analogWrite(LedPin, 128);
  }
  else{
    analogWrite(LedPin, 0);
  }
}

To do it "step less" between 0V and 1V

void setup() {
  const byte LedPin = 10;
  const byte VoltageIn = A0;
  
  pinMode(LedPin, OUTPUT);
  pinMode(VoltageIn, INPUT);

}

void loop() {
  int analogVal = analogRead(VoltageIn);
  
  analogWrite(LedPin, map(analogVal, 0, 205, 0, 255));
}

Or to have a minimum of 0.5V and step less between 0.5V and 1V

void setup() {
  const byte LedPin = 10;
  const byte VoltageIn = A0;
  
  pinMode(LedPin, OUTPUT);
  pinMode(VoltageIn, INPUT);

}

void loop() {
  int analogVal = analogRead(VoltageIn);
  
  if(analogVal >= 102){
    analogWrite(LedPin, map(analogVal, 0, 205, 0, 255));
  }
  else{
    analogWrite(LedPin, 0);
  }
}

You can get more accuracy (if needed) by setting INTERNAL1V1 internal reference.

Thank your septillion it help me a lot that is what I was trying to find to do :slight_smile: