Working w/ battery
This commit is contained in:
parent
65d77059a3
commit
58ffb0fbc6
|
@ -1,8 +1,11 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#define ADC_AREF 3.3f
|
||||||
|
#define BATVOLT_R1 2.0f
|
||||||
|
#define BATVOLT_R2 2.0f
|
||||||
|
#define BATVOLT_PIN BAT_VOLT
|
||||||
|
|
||||||
int getB()
|
int getB()
|
||||||
{
|
{
|
||||||
return (float)analogRead(BAT_VOLT);
|
return ((ADC_AREF / 1.023) * (BATVOLT_R1 + BATVOLT_R2) / BATVOLT_R2 * (float)analogRead(BATVOLT_PIN));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue