|
Re: How to use C with a Raspberry Pi servo HAT?
I ported the Adafruit servo HAT library to C++ for a personal project a while ago. Worked great for driving a few victors on a small robot. This is the HAT I used: https://www.adafruit.com/products/2327
Here's the source: https://github.com/4ndr3w/PiBot/blob...rivers/PWM.cpp
https://github.com/4ndr3w/PiBot/blob.../drivers/PWM.h
You'll need to link it with the WiringPI library.
Also be very careful if you're driving a large robot like this - if your program crashes/exits, the servo hat will keep outputting the last PWM value it was set at.
__________________
2012-2014: 225 Driver, Programmer & Co-Captain
2012-2014: FTC 4977 Driver, Programmer, & Team Captain
2011: 225 Operator & Programmer
2013: FRC: Springside-Chestnut Hill Winner (w/341 & 1495), Midknight Mayhem Winner (w/316, 369, & 869), Battle O' Baltimore Winner (w/1640, 2914 & 339), Duel on the Delaware Finalist (w/816 & 369), Ramp Riot Winner (w/341, 304, & 4637) FTC: PA State Finalist
2014: FRC: Springside-Chestnut Hill Winner (w/316 & 1495), Greater DC Winner (w/1731 & 4464), Midknight Mayhem Winner (w/25, 1626 & 329) FTC: PA State Champion
|