these are my coding...
#define BLYNK_PRINT Serial
#include <EEPROM.h>
#include "CurieIMU.h"
#include <BlynkSimpleCurieBLE.h>
#include <CurieBLE.h>
#include <Wire.h>
#include <SPI.h>
WidgetTerminal terminal(V2);
#define center A0 //Define FSR Sensor pins
#define left A1
#define right A2
#define buz 2
char auth[] = " 897e30dde9c14f518ff519e457696941"; //Enter your Blynk Authorization Code Here
BLEPeripheral blePeripheral;
int cal_weight;
int body_weight;
int fc, fr, fl;
int mr, ml, mc, cr, cl, cc;
int tempr, templ, tempc;
int cal_rec = 0;
int mem[10];
int val;
int x, y, z, thx, thy, thz;
int pin1;
int mode = 0;
void get_readings() {
for (int i = 0; i < 50; i++) {
fc = analogRead(center); //Get raw readings from sensors
fr = analogRead(right);
fl = analogRead(left);
thx = CurieIMU.readAccelerometer(X_AXIS);
thy = CurieIMU.readAccelerometer(Y_AXIS);
thz = CurieIMU.readAccelerometer(Z_AXIS);
delay(2);
}
fc = fc / 50;
fr = fr / 50;
fl = fl / 50;
thx = thx / 50; //Get the average values of the readings
thy = thy / 50;
thz = thz / 50;
}
void calibrate() {
while (mode == 1) {}
if (mode == 2) {
get_readings();
tempr = fr;
templ = fl; //Save the values of FSRs
tempc = fc;
}
while (mode == 3) {}
if (mode == 5) {
get_readings();
mr = (fr - tempr) / 100;
ml = (fl - templ) / 100;
mc = (fc - tempc) / 100; //Calculate threshold values
cr = 1000 - (mr * tempr);
cl = 1000 - (ml * templ);
cc = 1000 - (mc * tempc);
x = thx;
y = thy;
z = thz;
EEPROM.write(0, mr);
EEPROM.write(1, ml);
EEPROM.write(2, mc); //Write threshold values to EEProm
EEPROM.write(3, cr);
EEPROM.write(4, cl);
EEPROM.write(5, cc);
EEPROM.write(6, x);
EEPROM.write(7, y);
EEPROM.write(8, z);
}
}
void active() {
get_readings();
fc = fc * mc + cc; //Calculate forces on FSRs using pre-saved threshold values
fl = fl * ml + cl;
fr = fr * mr + cr;
if (abs(fl - fr) > 300) {
tone(buz, 300); //Alerts if straps are unbalanced
terminal.println("Straps are unbalanced");
}
if (fc > 500) {
tone(buz, 600); //Alerts if the backpack is overfilled
terminal.println("Harmful force on the spine.");
}
if (fl + fr > cal_weight) {
tone(buz, 1400); //Alerts if the backpack is over-weight
terminal.println("Too heavy");
}
if (abs(thx - x) > 30 or abs(thy - y) > 30 or abs(thz - z) > 30) { // Alerts about improper angles
tone(buz, 2000);
terminal.println("Harmful posture detected");
}
delay(500);
digitalWrite(buz, LOW);
}
void setup() {
pinMode(3, OUTPUT);
pinMode(left, INPUT);
pinMode(right, INPUT); //Setting the sensor pin modes
pinMode(center, INPUT);
mr = EEPROM.read(0);
ml = EEPROM.read(1);
mc = EEPROM.read(2); // Read the saved values from EEProm
cr = EEPROM.read(3);
cl = EEPROM.read(4);
cc = EEPROM.read(5);
thx = EEPROM.read(6);
thy = EEPROM.read(7);
thz = EEPROM.read(8);
Serial.begin(9600);
blePeripheral.setLocalName("Arduino101Blynk");
blePeripheral.setDeviceName("Arduino101Blynk");
blePeripheral.setAppearance(384);
Blynk.begin(auth, blePeripheral);
blePeripheral.begin();
}
void loop() {
Blynk.run();
blePeripheral.poll();
BLYNK_WRITE(V0)
{
body_weight = param.asInt();
}
cal_weight = body_weight / 10; // Calculate the safe carrying weight
BLYNK_WRITE(V1)
{
pin1 = param.asInt();
if (pin1 == 1) {
mode = mode + 1;
calibrate();
}
}
BLYNK_WRITE(V2) {
if (mode == 2) {
terminal.print("Put 1kg weight and Press Enter");
mode = mode + 1;
} // Terminal Notifications in the calibration process
if (mode == 3) {
terminal.println("Values Saved");
terminal.println("Put 2kg weight and Press Enter");
mode = mode + 1;
}
if (mode == 6) {
terminal.println("Values Saved");
terminal.println("Calibration Succesfull");
mode = 0;
active();
}
}
BLYNK_WRITE(V3) { // Enter button
int pin3 = param.asInt();
if (pin3 == 1) {
mode = mode + 1;
}
}
BLYNK_WRITE(V4) { // Turn On/Off the buzzer
int pin4 = param.asInt();
if (pin4 == 1) {
tone(buz , 1000);
}
if (pin4 == 0) {
digitalWrite(buz , LOW);
}
}
BLYNK_WRITE(V5) { //Turning on the device
int pinValue = param.asInt();
if (pinValue == 1) {
while (pinValue == 1) {
int pinValue = param.asInt();
active();
}
}
}
...
and these are the errors...someone hlp me pls
Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino 101"
C:\Users\neo19\Documents\Arduino\sketch_jan05b\sketch_jan05b.ino: In function 'void setup()':
C:\Users\neo19\Documents\Arduino\sketch_jan05b\sketch_jan05b.ino:140:34: warning: 'void BlynkCurieBLE::begin(const char*, BLEPeripheral&)' is deprecated (declared at C:\Users\neo19\Documents\Arduino\libraries\Blynk\src/BlynkSimpleCurieBLE.h:146) [-Wdeprecated-declarations]
Blynk.begin(auth, blePeripheral);
^
C:\Users\neo19\Documents\Arduino\sketch_jan05b\sketch_jan05b.ino: In function 'void loop()':
sketch_jan05b:153: error: a function-definition is not allowed here before '{' token
{
^
sketch_jan05b:159: error: a function-definition is not allowed here before '{' token
{
^
sketch_jan05b:212: error: expected '}' at end of input
}
^
exit status 1
a function-definition is not allowed here before '{' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.