Skip to content

Commit ee48aae

Browse files
authored
lora control LED
Receive the lora signal to control the on and off of the LED.
1 parent 8d7fb22 commit ee48aae

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+
Receive the lora signal to control the on and off of the LED.
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+
13+
#include "heltec.h"
14+
#include "string.h"
15+
#include "stdio.h"
16+
#define LED 25
17+
#define BAND 868E6 //you can set band here directly,e.g. 868E6,915E6
18+
char Readback[50];
19+
void setup() {
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(LED,OUTPUT);
23+
digitalWrite(LED,LOW);
24+
}
25+
26+
void loop() {
27+
// try to parse packet
28+
int packetSize = LoRa.parsePacket();
29+
if (packetSize) {
30+
// received a packet
31+
Serial.print("Received packet '");
32+
// read packet
33+
while (LoRa.available()) {
34+
sprintf(Readback+strlen(Readback),"%c",(char)LoRa.read());
35+
}
36+
Serial.print(Readback);
37+
if(strncmp(Readback, "OpenLED", strlen(Readback)) == 0) {
38+
digitalWrite(LED, HIGH);
39+
}
40+
else if(strncmp(Readback, "CloseLED", strlen(Readback)) == 0) {
41+
digitalWrite(LED, LOW);
42+
}
43+
memset(Readback,0,50);
44+
// print RSSI of packet
45+
Serial.print(" with RSSI ");
46+
Serial.println(LoRa.packetRssi());
47+
}
48+
}

0 commit comments

Comments
 (0)