-
Notifications
You must be signed in to change notification settings - Fork 6
/
wiring-gpio.c
39 lines (33 loc) · 940 Bytes
/
wiring-gpio.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
#include "wiring-gpio.h"
void cleaning(){
digitalWrite (0, LOW);
digitalWrite (2, LOW);
digitalWrite (3, LOW);
}
void doorlock(int open){
if (open){
digitalWrite (0, LOW);
digitalWrite (2, HIGH);
digitalWrite (3, HIGH) ;
delay (5000);
}else{ //close
digitalWrite (0, HIGH);
digitalWrite (2, LOW);
digitalWrite (3, LOW) ;
}
}
void setupWiring(){
wiringPiSetup () ;
// wiringPi pin 0 = Physical pin 11 (or BCM pin 17) on Raspberry Pi 2 B
pinMode (0, OUTPUT) ;
// wiringPi pin 2 = Physical pin 13 (or BCM pin 27) on Raspberry Pi 2 B
pinMode (2, OUTPUT) ;
// wiringPi pin 3 = Physical pin 15 (or BCM pin 22) on Raspberry Pi 2 B
pinMode (3, OUTPUT) ;
// red LED is always on when door is locked
digitalWrite (0, HIGH) ;
// green LED is always off when door is locked
digitalWrite (2, LOW) ;
// Door is locked
digitalWrite (3, LOW) ;
}