Created
January 1, 2017 21:05
-
-
Save aycabta/5c3149391d5c9429cd0a8a67625c9c24 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: test | |
test: test.o | |
gcc bcm2835-1.50/src/bcm2835.o test.o -o test | |
test.o: test.c | |
gcc -c -Ibcm2835-1.50/src/ test.c | |
clean: | |
rm test test.o |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bcm2835.h> | |
/* libbcm2835: http://www.airspayce.com/mikem/bcm2835/ */ | |
#define PWM_CHANNEL 0 | |
int main(int argc, char **argv) | |
{ | |
if (!bcm2835_init()) | |
return 1; | |
bcm2835_gpio_fsel(RPI_GPIO_P1_18, BCM2835_GPIO_FSEL_INPT); | |
bcm2835_pwm_set_mode(PWM_CHANNEL, 1, 1); | |
bcm2835_pwm_set_clock(1920); | |
bcm2835_pwm_set_range(PWM_CHANNEL, 200); | |
int angle = 0; | |
if (argc > 1) { | |
angle = atoi(argv[1]); | |
} | |
bcm2835_pwm_set_data(PWM_CHANNEL, angle); | |
bcm2835_close(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment