EasyManua.ls Logo

Freenove Ultimate Starter Kit - Page 109

Freenove Ultimate Starter Kit
286 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
109
Chapter 7 AD/DA Converter
www.freenove.com
support@freenove.com
value = analogRead(0) #read the ADC value of channel 0
analogWrite(value) # write ADC value
voltage = value / 255.0 * 3.3 # calculate voltage value
print ('ADC Value : %d, Voltage : %.2f'%(value,voltage))
time.sleep(0.01)
About smbus module:
smbus Module
That is System Management Bus.This module defines an object type that allows SMBus transactions on
hosts running the Linux kernel. The host kernel must have I2C support, I2C device interface support, and a
bus adapter driver. All of these can be either built-in to the kernel, or loaded from modules.
In Python, you can use help(smbus) to view the relevant function and their descriptions.
bus=smbus.SMBus(1)Create an SMBus class object.
bus.read_byte_data(address,cmd+chn) Read a byte of data from an address and return it.
bus.write_byte_data(address,cmd,value) Write a byte of data to an address.

Table of Contents