forked from untergasser/tempRainPi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransmit.cpp
executable file
·53 lines (51 loc) · 1.11 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
45
46
47
48
49
50
51
52
53
/*
* 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[] = "11111110011000001010010000101010110001000000011111111111011111110111010001010010101110111111010\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);
}