forked from ttn-zh/ic880a-gateway
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkitt.c
85 lines (73 loc) · 1.78 KB
/
kitt.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// blink.c
//
// Example program for bcm2835 library
// Blinks a pin on an off every 0.5 secs
//
// After installing bcm2835, you can build this
// with something like:
// gcc -o blink blink.c -l bcm2835
// sudo ./blink
//
// Or you can test it before installing with:
// gcc -o blink -I ../../src ../../src/bcm2835.c blink.c
// sudo ./blink
//
// Author: Mike McCauley ([email protected])
// Copyright (C) 2011 Mike McCauley
// $Id: RF22.h,v 1.21 2012/05/30 01:51:25 mikem Exp $
#include <bcm2835.h>
int pinArray[]={4,18,23,24,8,10,9,11,17};
int count =0;
int timer=400;
int i = 0;
int main(int argc, char **argv)
{
// If you call this, it will not actually access the GPIO
// Use for testing
// bcm2835_set_debug(1);
if (!bcm2835_init())
return 1;
// Set the pin to be an output
for (count=0;count<9;count++) {
bcm2835_gpio_fsel(pinArray[count], BCM2835_GPIO_FSEL_OUTP);
bcm2835_gpio_write(pinArray[count], LOW);
}
// Blink
while (1)
{
for (count = 0; count < 9; count++) {
// Turn it on
bcm2835_gpio_write(pinArray[count], HIGH);
// wait a bit
delay(timer);
// turn it off
bcm2835_gpio_write(pinArray[count], LOW);
// wait a bit
delay(timer);
}
for (count = 0; count < 9; count++) {
bcm2835_gpio_write(pinArray[count], HIGH);
}
for (count = 0; count < 9; count++) {
// Turn it off
bcm2835_gpio_write(pinArray[count], LOW);
// wait a bit
delay(timer);
// turn it on
bcm2835_gpio_write(pinArray[count], HIGH);
// wait a bit
delay(timer);
}
for (i = 0; i < 10; i++) {
for (count = 0; count < 9; count++) {
bcm2835_gpio_write(pinArray[count], LOW);
}
delay(timer);
for (count = 0; count < 9; count++) {
bcm2835_gpio_write(pinArray[count], HIGH);
}
delay(timer);
}
}
return 0;
}