void VCC()
{
#define Vref 1100
int mvVcc;
if ((foundSig >= 0) && (foundSig <= 8)) {
ADMUX = (1 << REFS0) | 0x0E;
ADCSRB = 0;
ADCSRA = (1 << ADEN) | (1 << ADATE) | (1 << ADSC) | 0x05;
delay(1);
mvVcc = (1023L * Vref) / ADC;
Serial.print(F("VCC = "));
Serial.print(mvVcc);
Serial.println(F(" mV"));
Serial.println();
}
if ((foundSig >= 14) && (foundSig <= 18)) {
ADMUX = (1 << REFS0) | 0x1E;
ADCSRB = 0;
ADCSRA = (1 << ADEN) | (1 << ADATE) | (1 << ADSC) | 0x05;
delay(1);
mvVcc = (1023L * Vref) / ADC;
Serial.print(F("VCC = "));
Serial.print(mvVcc);
Serial.println(F(" mV"));
Serial.println();
}
if ((foundSig >= 22) && (foundSig <= 23)) {
ADMUX = (1 << REFS0) | 0x1E;
ADCSRB = 0;
ADCSRA = (1 << ADEN) | (1 << ADATE) | (1 << ADSC) | 0x05;
delay(1);
mvVcc = (1023L * Vref) / ADC;
Serial.print(F("VCC = "));
Serial.print(mvVcc);
Serial.println(F(" mV"));
Serial.println();
}
if ((foundSig >= 29) && (foundSig <= 31)) {
ADMUX = 0x0E;
ADCSRB = 0;
ADCSRA = (1 << ADEN) | (1 << ADATE) | (1 << ADSC) | 0x05;
delay(1);
mvVcc = (1023L * Vref) / ADC;
Serial.print(F("VCC = "));
Serial.print(mvVcc);
Serial.println(F(" mV"));
Serial.println();
}
}
1 лайк