-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsend.cpp
64 lines (47 loc) · 936 Bytes
/
send.cpp
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
#include <wiringPi.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int pin;
int send(int time) {
digitalWrite(pin, 0);
delayMicroseconds(156);
digitalWrite(pin,1);
delayMicroseconds(26*time);
}
int main(int argc, char *argv[]) {
// Starte die WiringPi-Api (wichtig)
if (wiringPiSetup() == -1)
return 1;
pin = atoi(argv[1]);
unsigned int data = atol(argv[2]);
// Wichtig: Hier wird das WiringPi Layout verwendet
pinMode(7, OUTPUT);
int i;
unsigned int temp = data;
send(39);
for(i=15; i >= 0; i--) {
temp = data;
if (temp & ( (unsigned int) pow(2,i) )) {
//printf("1");
send(21);
} else {
//printf("0");
send(10);
}
}
send(39);
digitalWrite(7, 0);
return 0;
//digitalWrite(7, 1);
/*while(0) {
// LED an
digitalWrite(7, 1);
// Warte 100 ms
delay(1000);
// LED aus
digitalWrite(7, 0);
// Warte 100 ms
delay(1000);
}*/
}