EasyManuals Logo

Freenove Ultimate Starter Kit User Manual

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
Page #107 background imageLoading...
Page #107 background image
107
Chapter 7 AD/DA Converter
ā–ˆ www.freenove.com
support@freenove.com ā–ˆ
delay(100);
}
Details about analogRead() and analogWrite():
vo id a nalogWrite (int pin, int v alue) ;
This writes the given value to the supplied analog pin. You will need to register additional analog modules
to enable this function for devices.
in t a nalogRead (int pin) ;
This returns the value read on the supplied analog input pin. You will need to register additional analog
modules to enable this function for devices.
For more detailed instructions about PCF8591 of wiringPi, please refer to:
http://wiringpi.com/extensiones/i2c-pcf8591/
Python Code 7.1.1 ADC
First install a smbus module, and the command is as follows:
sudo apt-get install python-smbus
After the installation is completed, operate according to the following steps. Observe the project result, and
then analyze the code.
1. Use cd command to enter 07.1.1_ADC directory of Python code.
cd ~/Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi/Code/Python_Code/07.1.1_ADC
2. Use the python command to execute the Python code ā€œADC.pyā€.
python ADC.py
After the program is executed, shift the potentiometer, then the terminal will print out the potentiometer
voltage value and the converted digital content. When the voltage is greater than 1.6V (voltage need to turn
on red LED), LED starts emitting light. If you continue to increase the output voltage, the LED will become
more bright gradually.
The following is the code:
1
2
3
4
5
6
7
im port smbus
im port time
address = 0x48 #default address of PCF8591
bus=smbus.SMBus(1)
cmd=0x40 #command

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Freenove Ultimate Starter Kit and is the answer not in the manual?

Freenove Ultimate Starter Kit Specifications

General IconGeneral
BrandFreenove
ModelUltimate Starter Kit
CategorySingle board computers
LanguageEnglish