hi habe es mit eigenen versucht, aber es geht nicht :
schau hier:
const float RefVolt = 5;
const float R1 = 4700;
const float R2 = 4700;
const float ResistorDiv= (R1 + R2)/(1023.0*R2);
const int BatteryPin= 0;
const int speakerPin = 8;
void setup()
{
Serial.begin(9600);
pinMode(speakerPin,OUTPUT);
}
void loop()
{
int AD_value = analogRead(BatteryPin);
float VoltageIn= ResistorDiv * AD_value * RefVolt;
//Serial.println(AD_value);
Serial.println("Battery Voltage: ");
Serial.print(VoltageIn);
Serial.print("V");
Serial.println();
//Falls gemessene Batteriespannung <= 6.5V, Warnung ausgeben-> LED on
if (VoltageIn <= 7.00)
{
digitalWrite(speakerPin, HIGH);
delayMicroseconds(500);
digitalWrite(speakerPin,LOW);
delayMicroseconds(500);
}
//Wenn größer 7V, Batterie ok
else
{
digitalWrite(speakerPin, LOW);
}
delay(4000);
}