Skip to content

Commit 189d073

Browse files
authored
lora control LED, sender code
Send a lora signal to control the LED light switch of another board.
1 parent ee48aae commit 189d073

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
Send a lora signal to control the LED light switch of another board.
3+
Pull the 12th pin high to turn on the LED light.
4+
Pull pin 13 high to turn off the LED light.
5+
by Aaron.Lee from HelTec AutoMation, ChengDu, China
6+
成都惠利特自动化科技有限公司
7+
www.heltec.cn
8+
9+
this project also realess in GitHub:
10+
https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series
11+
*/
12+
#include "heltec.h"
13+
#define BAND 868E6 //you can set band here directly,e.g. 868E6,915E6
14+
15+
int counter = 0;
16+
#define Open_LED 12
17+
#define Close_LED 13
18+
void setup() {
19+
20+
//WIFI Kit series V1 not support Vext control
21+
Heltec.begin(false /*DisplayEnable Enable*/, true /*Heltec.LoRa Disable*/, true /*Serial Enable*/, true /*PABOOST Enable*/, BAND /*long BAND*/);
22+
pinMode(Open_LED,INPUT);
23+
digitalWrite(Open_LED,LOW);
24+
pinMode(Close_LED,INPUT);
25+
digitalWrite(Close_LED,LOW);
26+
LoRa.setTxPower(14,RF_PACONFIG_PASELECT_PABOOST);
27+
28+
}
29+
30+
void loop() {
31+
if(digitalRead(Open_LED)){
32+
Serial.print("Sending packet: OpenLED\r\n");
33+
// send packet
34+
LoRa.beginPacket();
35+
LoRa.print("OpenLED");
36+
LoRa.endPacket();
37+
digitalWrite(Open_LED,LOW);
38+
}
39+
if(digitalRead(Close_LED)){
40+
Serial.print("Sending packet: CloseLED\r\n");
41+
// send packet
42+
LoRa.beginPacket();
43+
LoRa.print("CloseLED");
44+
LoRa.endPacket();
45+
digitalWrite(Close_LED,LOW);
46+
}
47+
delay(1000);
48+
}

0 commit comments

Comments
 (0)