Adafruit_Learning_System_Gu.../Introducing_Feather_M0_Express/code.py
2022-02-18 17:22:12 -05:00

16 lines
341 B
Python
Executable file

# SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: MIT
import board
import analogio
vbat_voltage = analogio.AnalogIn(board.D9)
def get_voltage(pin):
return (pin.value * 3.3) / 65536 * 2
battery_voltage = get_voltage(vbat_voltage)
print("VBat voltage: {:.2f}".format(battery_voltage))