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 #78 background imageLoading...
Page #78 background image
Chapter 4 Analog & PWM
78
www.freenove.com
support@freenove.com
The wiringPi library of C provides a hardware PWM method, while wiringPi library of Python doesn’t provide
hardware PWM method. There is only software PWM for Python.
The hardware PWM only needs to be configured, does not occupy CPU resources, and is more precise in time
control. The software PWM requires the CPU to work all the time, using the code to output high level and low
level. This part of the code is carried out in multi-thread, and the time precision is relatively not high enough.
In Python, you can set its frequency. The duty cycle range is 0-100. You can set duty cycle with decimals, so
although it is 0-100, you set more than 100 levels.
For more details, please refer http://wiringpi.com/reference/software-pwm-library/
Circuit
Schematic diagram
Hardware connection
Code
This project is designed to make PWM output GPIO18 with pulse width increasing from 0% to 100%, and then
reducing from 100% to 0% gradually.
C Code 4.1.1 BreathingLED
First observe the project result, and then analyze the code.
1. Use cd command to enter 04.1.1_BreathingLED directory of C code.
cd ~/Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi/Code/C_Code/04.1.1_BreathingLED
2. Use following command to compile BreathingLED.c” and generate executable fileBreathingLED”.
gcc BreathingLED.c -o BreathingLED -lwiringPi
3. Then run the generated file BreathingLED
sudo ./ BreathingLED

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