forked from ZerBea/hcxdumptool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhcxpioff.c
49 lines (45 loc) · 849 Bytes
/
hcxpioff.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
#define _GNU_SOURCE
#include <signal.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wiringPi.h>
/*===========================================================================*/
int main()
{
int ret;
if(wiringPiSetup() == -1)
{
puts("wiringPi failed!");
system("poweroff");
}
pinMode(0, OUTPUT);
pinMode(7, INPUT);
while(1)
{
digitalWrite(0, HIGH);
delay (250);
digitalWrite(0, LOW);
delay (250);
digitalWrite(0, HIGH);
delay (250);
digitalWrite(0, LOW);
delay (250);
if(digitalRead(7) == 1)
{
digitalWrite(0, HIGH);
ret = system("poweroff");
if(ret != 0)
{
puts("poweroff failed!");
exit(EXIT_FAILURE);
}
}
sleep(10);
}
return EXIT_SUCCESS;
}
/*===========================================================================*/