Created
March 6, 2014 16:59
-
-
Save hsiboy/9394300 to your computer and use it in GitHub Desktop.
Raspberry Pi - BCM2835 - Getting to blinky
This file contains 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
// 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