Skip to content

Commit 52b8af1

Browse files
committed
adding picowbell doubler battery examples
1 parent 40d73b2 commit 52b8af1

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

PiCowbell_Doubler/Arduino_PiCowbell_Doubler_Battery_Monitor/.pico_rp2040.test.only

Whitespace-only changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SPDX-FileCopyrightText: 2024 ladyada for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
import time
6+
import board
7+
from analogio import AnalogIn
8+
from digitalio import DigitalInOut, Direction
9+
10+
led = DigitalInOut(board.LED)
11+
led.direction = Direction.OUTPUT
12+
13+
analog_in = AnalogIn(board.A3)
14+
15+
def get_vsys(pin):
16+
return ((pin.value * 3) * 3.3) / 65536
17+
18+
while True:
19+
led.value = True
20+
print(f"The battery level is: {get_vsys(analog_in):.1f}V")
21+
led.value = False
22+
time.sleep(5)

0 commit comments

Comments
 (0)