add examples

This commit is contained in:
2021-12-14 11:30:20 +01:00
parent c4c5e65f64
commit 20b30eee1f
13 changed files with 625 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
#include <Battery.h>
Battery battery(3400, 4200, A0);
/**
* 1 cell li-ion/li-poly battery wired to A0 before voltage booster, on demand sensing on pin 3, linear mapping function
* https://github.com/rlogiacco/BatterySense#lesser-than-5v-with-voltage-booster
**/
void setup() {
Serial.begin(9600);
while (!Serial);
battery.begin(5000, 1.0);
}
void loop() {
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
Serial.print("Battery voltage is ");
Serial.print(battery.voltage());
Serial.print(" (");
Serial.print(battery.level());
Serial.println("%)");
}