0% found this document useful (0 votes)
8 views4 pages

Button

Uploaded by

troudif5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Button

Uploaded by

troudif5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

LORA RECEIVER

#include <SPI.h>

#include <LoRa.h>

int LED = 3;

String inString = ""; // string to hold input

int val = 0;

void setup() {

Serial.begin(9600);

pinMode(LED,OUTPUT);

while (!Serial);

Serial.println("LoRa Receiver");

if (!LoRa.begin(433E6)) { // or 915E6

Serial.println("Starting LoRa failed!");

while (1);

}
void loop() {

// try to parse packet

int packetSize = LoRa.parsePacket();

if (packetSize) {

// read packet

while (LoRa.available())

int inChar = LoRa.read();

inString += (char)inChar;

val = inString.toInt();

inString = "";

LoRa.packetRssi();

Serial.println(val);

analogWrite(LED , val);

delay (100);

}
LORA TRANSMITTER :

#include <SPI.h>

#include <LoRa.h>

int pot = A0;

void setup() {

Serial.begin(9600);

pinMode(pot,INPUT);

while (!Serial);

Serial.println("LoRa Sender");

if (!LoRa.begin(433E6)) { // or 915E6, the MHz speed of yout module

Serial.println("Starting LoRa failed!");

while (1);

void loop() {

int val = map(analogRead(pot),0,1024,0,255);

LoRa.beginPacket();

LoRa.print(val);

LoRa.endPacket();

delay(50);

You might also like