- Hands-On Robotics Programming with C++
- Dinesh Tavasalkar
- 259字
- 2021-06-24 15:30:34
The softPWM library
wiringPi consists of a softPWM library, using which we can get PWM signal output from any data pin of the RPi. The softPWM library contains two main functions: softPwmCreate and softPwmWrite. Both of these functions work as follows:
softPwmCreate(pin number, initial duty cycle value, max duty cycle value);
The softPwmCreate function is used to create a PWM pin. It consists of three main parameters:
- pin number: Pin number represents the wiringPi pin that we want to set as a PWM pin.
- initial duty cycle value: In initial duty cycle value we have to provide as the minimum value of the duty cycle. The initial duty cycle value is ideally set to 0.
- max duty cycle value: In the max duty cycle value, we have to provide the maximum value of the duty cycle. This value must be set to 100:
softPwmWrite(pin number, duty cycle value);
The softPwmWrite function is used to write PWM data on the output device (for example, LED). It consists of two parameters:
- pin number: Pin number represents the wiringPi pin on which we have to write the PWM data.
- duty cycle value: In this parameter, we have to provide the duty cycle value. The duty cycle value must be between the initial duty cycle value and max duty cycle value, that is, in the range of 0 to 100.
Now that we understand the two functions inside the softPWM library, we will write a simple C++ program to make an LED blink at different intensities.
推薦閱讀
- Python 深度學習
- 深入理解Java7:核心技術與最佳實踐
- 利用Python進行數據分析(原書第3版)
- 表哥的Access入門:以Excel視角快速學習數據庫開發(第2版)
- 小學生C++創意編程(視頻教學版)
- VMware虛擬化技術
- Getting Started with Gulp
- Selenium Testing Tools Cookbook(Second Edition)
- Python極簡講義:一本書入門數據分析與機器學習
- 現代C++編程實戰:132個核心技巧示例(原書第2版)
- Photoshop智能手機APP界面設計
- 絕密原型檔案:看看專業產品經理的原型是什么樣
- Tkinter GUI Application Development Blueprints
- Learning Rust
- Puppet Essentials