BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Trying to integrate Processing with Blynk and Arduino

lcd

#1

I’m using four vibration sensors. when one of them reaches a certain threshold, I want the Blynk LCD to go from “No Drilling” to (for A sensor for example) “A Sensor detected”. Simultaneously, I want processing to draw a box on the appropriate coordinate. This is my code. How can i get both of these things to work?

int MEASa = A0;
int MEASb = A1;
int MEASc = A2;
int MEASd = A3;
#define BLYNK_PRINT Serial
#include <SoftwareSerial.h>
#include <BlynkSimpleSerialBLE.h>
char auth[] = "a4c574cc407743579f81094624f8bd38";
SoftwareSerial SerialBLE(10, 11); // RX, TX

BlynkTimer timer;
void Sensor1() {
int MEASvala = analogRead(MEASa);
  Serial.print("A:" );
  Serial.println(MEASa);
if(MEASvala > 500){
  Serial.write('1');
  Blynk.virtualWrite(V1, "A Sensor");
  Blynk.virtualWrite(V2, "Detected");
}
else {
  Blynk.virtualWrite(V1, "No");
  Blynk.virtualWrite(V2, "Drilling");
}
}
void Sensor2() {
int MEASvalb = analogRead(MEASb);
   Serial.print("B:" );
  Serial.println(MEASb);

if(MEASvalb > 500){
  Serial.write('2');
  Blynk.virtualWrite(V3, "B Sensor");
  Blynk.virtualWrite(V4, "Detected");
}
else {
  Blynk.virtualWrite(V3, "No");
  Blynk.virtualWrite(V4, "Drilling");
}
}
void Sensor3() {
int MEASvalc = analogRead(MEASc);
 Serial.print("C:" );
  Serial.println(MEASc);
if(MEASvalc > 500){
  Serial.write('3');
  Blynk.virtualWrite(V5, "C Sensor");
  Blynk.virtualWrite(V6, "Detected");
}
else {
  Blynk.virtualWrite(V5, "No");
  Blynk.virtualWrite(V6, "Drilling");
}
}
void Sensor4() {
int MEASvald = analogRead(MEASd);
 Serial.print("D:" );
  Serial.println(MEASd);
if(MEASvald > 500){
  Serial.write('4');
  Blynk.virtualWrite(V7, "D Sensor");
  Blynk.virtualWrite(V8, "Detected");
}
else {
  Blynk.virtualWrite(V7, "No");
  Blynk.virtualWrite(V8, "Drilling");
}
}
void setup() {
Serial.begin(9600);
  SerialBLE.begin(9600);
  Blynk.begin(SerialBLE, auth);
  Serial.println("Waiting for connections...");
timer.setInterval(1000L, Sensor1);
timer.setInterval(1000L, Sensor2);
timer.setInterval(1000L, Sensor3);
timer.setInterval(1000L, Sensor4);
}

void loop() {
  Blynk.run();
  timer.run();
}

#2

Hello.

First, as per the instructions you erased in order to post here :wink: … please format all pasted code (I fixed your post).

Blynk - FTFC

Secondly, this is the Blynk forum, not the Processing forum… we can try to help you learn how Blynk works, but any programming skills are up to you to learn through proper teaching resources on the web or otherwise.

Get your Processing code working first. then add in the Blynk aspects… since Blynk is really another library for an IoT GUI interface and not an OS, it works as an additional layer, not the primary controller.


#3

Also… this is a bad idea… this will try to run all four functions at the exact same time every second.

Stagger your timers to give each function time to complete before running the next.