-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransmitter.c
51 lines (39 loc) · 1.02 KB
/
transmitter.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
40
41
42
43
44
45
46
47
48
49
50
51
#include <VirtualWire.h>
/*
* Arduino 433MHz Transmitter Demo
*
* Donovan Prehn
* Peter Scherminski
*/
/* Physical Connections
*
* NANO -> FS1000A
* 5V ----------- VCC
* GND ----------- GND
* D13 ----------- ATAD
* A0 ----------- Light Dependent Resistor
*/
const int numberBase = 10; //Decimal Base
const int transmitPin = 12; //D12
const int analogInputPin = 0; //A0
char lightValueString[4];
void setup() {
//USB Serial Monitor Debugging
Serial.begin(9600);
Serial.println("setup()");
//VirtualWire
vw_set_ptt_inverted(true);
vw_setup(2000);
}
void loop() {
//Read Light Value
int analogLightValue = analogRead(analogInputPin);
itoa(analogLightValue, lightValueString, numberBase);
//Debug
Serial.print("Light CharMsg: ");
Serial.println(lightValueString);
//Transmit Light Value
vw_send((uint8_t *)lightValueString, strlen(lightValueString));
vw_wait_tx(); // Wait until the whole message is gone
delay(200);
}