Skip to content

Instantly share code, notes, and snippets.

@hsiboy
Created March 6, 2014 16:59
Show Gist options
  • Save hsiboy/9394300 to your computer and use it in GitHub Desktop.
Save hsiboy/9394300 to your computer and use it in GitHub Desktop.
Raspberry Pi - BCM2835 - Getting to blinky
// blinky.c
//
// gcc -o blinky blinky.c -l bcm2835
// must be run as root
// sudo ./blinky
#include <bcm2835.h>
// Blinks on RPi Plug P1 pin 13 (which is GPIO pin 21)
#define PIN RPI_GPIO_P1_13
int main(int argc, char **argv)
{
if (!bcm2835_init())
return 1;
// Set the pin to be an output
bcm2835_gpio_fsel(PIN, BCM2835_GPIO_FSEL_OUTP);
while (1)
{
// Turn it on
bcm2835_gpio_write(PIN, HIGH);
bcm2835_delay(500);
bcm2835_gpio_write(PIN, LOW);
bcm2835_delay(500);
}
bcm2835_close();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment