-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLyncTransmit.ino
More file actions
65 lines (56 loc) · 1.47 KB
/
LyncTransmit.ino
File metadata and controls
65 lines (56 loc) · 1.47 KB
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
64
65
// transmitterLync.pde
//
// This is implementetion for sending the status of Lync
// Presence for the led reciver
// Message format:
// <ID> <command> <arg1> <arg2> ... <argN>
#include <VirtualWire.h>
char msg[VW_MAX_MESSAGE_LEN];
uint8_t msgCounter = 0;
void setup()
{
Serial.begin(9600); // Debugging only
//Serial.println("setup");
// Initialise the IO and ISR
vw_set_ptt_inverted(false); // Required for DR3100
vw_setup(2000); // Bits per sec
}
void loop()
{
int num;
boolean doTransmit = false;
if (Serial.available() > 0)
{
digitalWrite(13, true); // Flash a light to show transmitting
while(!doTransmit)
{
num = Serial.available();
if (num == 0)
{
break;
}
else
{
msg[msgCounter] = Serial.read();
if (msg[msgCounter] == 0x7c)
{
Serial.println("");
doTransmit = true;
break;
}
else
{
Serial.print(msg[msgCounter],HEX);
msgCounter++;
}
}
}
if (doTransmit == true)
{
vw_send((uint8_t *)msg, msgCounter);
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13, false);
msgCounter = 0; // prepare for new message
}
}
}