Shows how to use PWM to control GPIO pins
#include <bcm2835.h>
#include <stdio.h>
#define PIN RPI_GPIO_P1_12
#define PWM_CHANNEL 0
#define RANGE 1024
int main(int argc, char **argv)
{
return 1;
int direction = 1;
int data = 1;
while (1)
{
if (data == 1)
direction = 1;
else if (data == RANGE-1)
direction = -1;
data += direction;
}
return 0;
}
@ BCM2835_GPIO_FSEL_ALT5
Definition: bcm2835.h:895
void bcm2835_delay(unsigned int millis)
Definition: bcm2835.c:539
void bcm2835_gpio_fsel(uint8_t pin, uint8_t mode)
Definition: bcm2835.c:302
int bcm2835_close(void)
Definition: bcm2835.c:2163
int bcm2835_init(void)
Definition: bcm2835.c:2008
void bcm2835_pwm_set_clock(uint32_t divisor)
Definition: bcm2835.c:1900
void bcm2835_pwm_set_data(uint8_t channel, uint32_t data)
Definition: bcm2835.c:1968
void bcm2835_pwm_set_mode(uint8_t channel, uint8_t markspace, uint8_t enabled)
Definition: bcm2835.c:1919
void bcm2835_pwm_set_range(uint8_t channel, uint32_t range)
Definition: bcm2835.c:1956