My code:
#include <Blynk.h>
#define BLYNK_PRINT Serial
const int FSR_PIN = A0; // Pin connected to FSR/resistor divider
// Measure the voltage at 5V and resistance of your 3.3k resistor, and enter
// their value's below:
const float VCC = 3.94; // Measured voltage of Ardunio 5V line
const float R_DIV = 3000.0; // Measured resistance of 3.3k resistor
// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
#include <BlynkSimpleSerialBLE.h>
SoftwareSerial SerialBLE(10, 11);
int steps = 0;
int pinValue;
BLYNK_WRITE(V3)
{
pinValue = param.asInt(); // assigning incoming value from pin V3 to a variable
// process received value
if (pinValue == 1) {
steps = 0;
Blynk.virtualWrite(V2, 0);
}
}
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "47ea30fe632b458485e9ebd69fa3d35e";
void setup()
{
// Blynk will work through Serial
// Do not read or write this serial manually in your sketch
Serial.begin(9600);
SerialBLE.begin(9600);
Blynk.begin(SerialBLE, auth);
pinMode(7, INPUT);
Blynk.virtualWrite(V2, 0);
}
int i = 0;
void loop()
{
Blynk.run();
int fsrADC = analogRead(FSR_PIN);
if (fsrADC != 0) // If the analog reading is non-zero
{
// Use ADC reading to calculate voltage:
float fsrV = fsrADC * VCC / 1023.0;
// Use voltage and static resistor value to
// calculate FSR resistance:
float fsrR = R_DIV * (VCC / fsrV - 1.0);
// Guesstimate force based on slopes in figure 3 of
// FSR datasheet:
float force;
float fsrG = 1.0 / fsrR; // Calculate conductance
// Break parabolic curve down into two linear slopes:
if (fsrR <= 600)
force = (fsrG - 0.00075) / 0.00000032639;
else
force = fsrG / 0.000000642857;
if (i % 5 == 0) {
Blynk.virtualWrite(V1, force);
}
i++;
delay(100);
}
if (digitalRead(7) == HIGH) {
steps++;
Blynk.virtualWrite(V2, steps);
delay(100);
}
}
When I upload, blynk shows it the way i want. But i need to present in front of others my project which is a smart shoe that connects to bluetooth. The bluetooth disconnects like every few seconds. ON serial monitor it shows (ready ping) for a few seconds and it works on the app. then it keep looping reconnecting for like 20 seconds then again ready for only few seconds.
I need it to be steady ready for atleast a minute to be able to show my project!
please I need help ASAP im presenting on Saturday in NYC