First of all say that I’m pretty new with coding so bare with me
I’m starting a new project and I need communication between two Arduino Uno boards. I followed all the examples and tutorials and came with this code. I’m not sure if it makes any sense or if it could be improved, any recommendation/suggestion will be much appreciated.
Want to make sure I’m moving the right direction before going any further.
The idea is to have a fsr connected to Arduino A and whenever the reading of the fsr is > 300 trigger a led to go HIGH on the Arduino B.
Code Arduino A (Sender):
const int led = 13;
int fsrPin = 0;
int fsrReading;
WidgetBridge bridge1(V1);
BLYNK_CONNECTED()
{
bridge1.setAuthToken("OtherAuthToken");
}
void setup()
{
SwSerial.begin(9600);
Serial.begin(9600);
Blynk.begin(Serial, auth);
}
void loop()
{
fsrReading = analogRead(fsrPin);
bridge1.virtualWrite(V5, fsrReading);
if (fsrReading <= 300) {
bridge1.digitalWrite(led, LOW);
}
if (fsrReading > 300) {
bridge1.digitalWrite(led, HIGH);
}
Blynk.run();
}
Code Arduino B (Receiver):
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX
#include <BlynkSimpleStream.h>
char auth[] = "YourAuthToken";
const int led = 13;
int fsrPin = 0;
int fsrReading;
BLYNK_WRITE(V1)
{
int pinData = param.asInt();
}
void setup()
{
SwSerial.begin(9600);
Serial.begin(9600);
Blynk.begin(Serial, auth);
}
void loop(){
Blynk.run();
}