![Freenove Raspberry Pi 2 Model B Manual Download Page 83](http://html.mh-extra.com/html/freenove/raspberry-pi-2-model-b/raspberry-pi-2-model-b_manual_2330437083.webp)
Need support?
81
Chapter 3 Module test (Required)
█
www.freenove.com
The code is as below:
1
2
3
4
5
6
7
8
9
10
11
from
ADS7830
import
*
adc=ADS7830()
def
test_Adc
():
try
:
while
True
:
Power=adc.readAdc(0)/255.0*5.0*3
(
"The battery voltage is "
+
str
(Power)+
"V"
)
time.sleep(1)
(
'\n'
)
except
KeyboardInterrupt
:
(
"\nEnd of program"
)
Reference
readAdc (channel)
This function has one parameter for reading the ADC value of the corresponding channel.
For example:
readAdc (0)
Read the ADC value of the batteries voltage. The returned number ranges between 0-255. Divide the
obtained value by 255.0 and then multiply by the reference voltage of 5.0V, and then triple the value to
get the batteries voltage.
Summary of Contents for Raspberry Pi 2 Model B
Page 35: ...Need support support freenove com 33 Chapter 0 Raspberry Pi Preparation www freenove com ...
Page 71: ...Need support support freenove com 69 Chapter 2 Assemble Robot www freenove com M3 Nut M3x12 ...
Page 98: ...Need support support freenove com 96 Chapter 4 Robot Dog www freenove com ...