-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtransmit.cpp
44 lines (42 loc) · 1.09 KB
/
transmit.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
/*
* Receiver for data of wireless weather sensors with RX868 and Raspberry Pi.
*
* Main program.
*/
#include <wiringPi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char sendSig[] = "11111110011011001110010011010110001010100000000111111111101100011111111010010011110011101011100\0";
// char sendSig[] = "11111110011011001110010101010100001010100000000111111110101001010111000010010010111110011110000\0";
int main() {
wiringPiSetup();
/*
BCM GPIO 17: DATA (OUT) == WiPin 0
*/
pinMode(0, OUTPUT);
digitalWrite(0, 0);
for (int i = 0 ; i < strlen(sendSig) ; i++) {
digitalWrite(0, 1);
if (sendSig[i] == '1') {
delayMicroseconds(480);
} else {
delayMicroseconds(1460);
}
digitalWrite(0, 0);
delayMicroseconds(940);
}
delayMicroseconds(34500);
for (int i = 0 ; i < strlen(sendSig) ; i++) {
digitalWrite(0, 1);
if (sendSig[i] == '1') {
delayMicroseconds(480);
} else {
delayMicroseconds(1460);
}
digitalWrite(0, 0);
delayMicroseconds(940);
}
digitalWrite(0, 0);
printf("Signal send:\n%s\n", sendSig);
}