forked from tdamdouni/Raspberry-Pi-DIY-Projects
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathled.c
executable file
·49 lines (39 loc) · 855 Bytes
/
led.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
#include <sys/types.h>
#include <unistd.h>
#include <assert.h>
#include "pump.h"
#include "wiringPi.h"
#define LOGGING "/tmp/gettemp.log"
/**
**/
static bool wiringPiActive = false;
void wiringPiInit(void) {
if (!wiringPiActive) {
wiringPiSetup();
wiringPiActive = true;
}
}
void led_on(int pin) {
bool result = false;
assert(wiringPiActive == true);
digitalWrite(pin,HIGH);
}
void led_off(int pin) {
bool result = false;
assert(wiringPiActive == true);
digitalWrite(pin,LOW);
}
void gpio_pin_mode(int pin, int mode) {
assert(wiringPiActive == true);
pinMode(pin,mode);
}
void initLed() {
wiringPiInit();
pinMode(GPIO_PIN_LED,OUTPUT);
}
void testLed() {
pinMode(GPIO_PIN_LED,OUTPUT);
digitalWrite(GPIO_PIN_LED,HIGH);
sleep(2);
digitalWrite(GPIO_PIN_LED,LOW);
}