Comments (2)
Sure! I think the examples in the examples
directory can probably help you out.
Hardware PWM servo example: https://github.com/golemparts/rppal/blob/master/examples/pwm_servo.rs
Software-based PWM servo example: https://github.com/golemparts/rppal/blob/master/examples/gpio_servo_softpwm.rs
While both hardware and software-based PWM will work, software-based PWM is inherently inaccurate on a multi-threaded OS due to scheduling/preemption. If you only need up to two PWM channels, I recommend just sticking with hardware PWM.
Be careful when hooking up a servo to your Pi. If you power your servo directly from the Pi's 5 V output, a current spike caused by the servo starting up or stalling could best case temporarily blow the polyfuse, worst case permanently damage your Pi. Most 9g micro servos are probably safe enough if you only connect a single servo, but definitely check its maximum ratings in the datasheet, or use an external power supply (connect the grounds together) to be safe. You'll also need to connect the control signal line to the relevant PWM pin.
from rppal.
Oh, I'm so sorry that I didn't looked into the example folder. I'm feeling so terribly stupid now.
Your reply is really what I was looking for.
I'll use an external power supply, just in case. Thanks for the heads up!
Thank you so much!
from rppal.
Related Issues (20)
- Does rppal support non-blocking SPI? HOT 2
- Soft PWM broken in 0.14.0 - subtraction undeflow error HOT 1
- cargo check yields errors after adding to Cargo.toml HOT 3
- GPIO starts fluctating HOT 1
- Set multiple pins at once? HOT 2
- Interrupt service routines for Timers? HOT 1
- is there any clear or clean or cleanup method? HOT 3
- Wrong library. My mistake. HOT 1
- Raspberry Pi5 HOT 53
- Banana Pi M5 support HOT 2
- Support concurrent reading and writing via Uart
- Using rppal with embedded_hal_async (async support) HOT 8
- Hardware field removed from /proc/cpuinfo causing identification issues HOT 5
- GPIO `is_low` output differs from rppal v0.17.0 impl compared to embedded-hal v1 impl
- No PWM on a raspberry pi 5 HOT 13
- Input pin mode not set correctly on Raspberry Pi 5 HOT 1
- Add an example of graceful shutdown when SIGINT (GPIO) HOT 1
- I2C connection with ADS1115 HOT 2
- pwm (or more specififally: ) the example `pwm_blinkled.rs` does not seem to work on my raspberry pi zero w HOT 6
- Multiple slave select lines on one SPI bus
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rppal.