pikeyd165 – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | // blink.c |
2 | // |
||
3 | // Example program for bcm2835 library |
||
4 | // Blinks a pin on an off every 0.5 secs |
||
5 | // |
||
6 | // After installing bcm2835, you can build this |
||
7 | // with something like: |
||
8 | // gcc -o blink blink.c -l bcm2835 |
||
9 | // sudo ./blink |
||
10 | // |
||
11 | // Or you can test it before installing with: |
||
12 | // gcc -o blink -I ../../src ../../src/bcm2835.c blink.c |
||
13 | // sudo ./blink |
||
14 | // |
||
15 | // Author: Mike McCauley |
||
16 | // Copyright (C) 2011 Mike McCauley |
||
17 | // $Id: RF22.h,v 1.21 2012/05/30 01:51:25 mikem Exp $ |
||
18 | |||
19 | #include <bcm2835.h> |
||
20 | #include <stdio.h> |
||
21 | |||
22 | // Blinks on RPi Plug P1 pin 11 (which is GPIO pin 17) |
||
23 | #define PIN RPI_GPIO_P1_11 |
||
24 | |||
25 | int main(int argc, char **argv) |
||
26 | { |
||
27 | // If you call this, it will not actually access the GPIO |
||
28 | // Use for testing |
||
29 | // bcm2835_set_debug(1); |
||
30 | |||
31 | if (!bcm2835_init()) |
||
32 | return 1; |
||
33 | |||
34 | // Set the pin to be an output |
||
35 | bcm2835_gpio_fsel(PIN, BCM2835_GPIO_FSEL_OUTP); |
||
36 | |||
37 | // Blink |
||
38 | while (1) |
||
39 | { |
||
40 | // Turn it on |
||
41 | bcm2835_gpio_write(PIN, HIGH); |
||
42 | |||
43 | // wait a bit |
||
44 | bcm2835_delay(500); |
||
45 | |||
46 | // turn it off |
||
47 | bcm2835_gpio_write(PIN, LOW); |
||
48 | |||
49 | // wait a bit |
||
50 | bcm2835_delay(500); |
||
51 | } |
||
52 | bcm2835_close(); |
||
53 | return 0; |
||
54 | } |
||
55 |