here is the code
#include <NewPing.h>
/**************************************************************
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Blynk community: http://community.blynk.cc
Social networks: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
This example shows how to use ordinary Arduino Serial
to connect your project to Blynk.
Feel free to apply it to any other example. It’s simple!
USB HOWTO: http://tiny.cc/BlynkUSB
**************************************************************/
// You could use a spare Hardware Serial on boards that have it (like Mega)
//distance measuring printed to blynk lcd screen
//blynk over usb definitions
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3); // RX, TX
#define BLYNK_PRINT SwSerial
//#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleStream.h>
//#include “blynk/blynk.h”
//newping library definitions
#include <NewPing.h>
#define TRIGGER_PIN 4 // trigger pin on the ultrasonic sensor.
#define ECHO_PIN 2 // echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance in centimeter.
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “adfbdd263fa149f5ab76d2c58260335e”;
WidgetLCD lcd(V1);
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
//variables used in smothing the values from distance sensor
const int numReadings = 50; //number of readings
String distance; //make average to string later
int readings[numReadings]; // the readings from the analog input
int readIndex = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; //the average value
//void setup()
//{
// Debug console
//DebugSerial.begin(9600);
// Blynk will work through Serial
//SwSerial.begin(9600);
//Blynk.begin(auth);
void setup() {
SwSerial.begin(9600);
Blynk.begin(auth);
// initialize all the readings to 0:
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
while (Blynk.connect() == false) {
// Wait until connected
}
}
// initialize all the readings to 0:
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
}
while (Blynk.connect() == false) {
// Wait until connected
}
}
void code{ //smoothing values from distance sensor
// subtract the last reading:
total = total - readings[readIndex];
// read from the sensor:
readings[readIndex] = sonar.ping_cm();
// add the reading to the total:
total = total + readings[readIndex];
// advance to the next position in the array:
readIndex = readIndex + 1;
// if we’re at the end of the array…
if (readIndex >= numReadings) {
// …wrap around to the beginning:
readIndex = 0;
}
// calculate the average:
average = total / numReadings;
// send it to the computer as ASCII digits
distance = average; // convert to string
//print to lcd
lcd.clear(); //Use it to clear the LCD Widget
lcd.print(4, 0, distance); //print the average distance
lcd.print(4, 1, “cm”);
delay(30);
}
void loop()
{
Blynk.run();
code()
}
and this the error
Continuing the discussion from Simple code error compiling:
Arduino: 1.6.12 (Windows 10), Board: “Arduino/Genuino Uno”
F:\aa\Arduino_Serial_USB_connect_test\Arduino_Serial_USB_connect_test.ino: In function ‘void setup()’:
Arduino_Serial_USB_connect_test:70: error: no matching function for call to ‘BlynkStream::begin(char [33])’
Blynk.begin(auth);
^
F:\aa\Arduino_Serial_USB_connect_test\Arduino_Serial_USB_connect_test.ino:70:19: note: candidate is:
In file included from C:\Users\varuramaprasad\Documents\Arduino\libraries\blynk-library-0.3.10\src/BlynkSimpleStream.h:18:0,
from F:\aa\Arduino_Serial_USB_connect_test\Arduino_Serial_USB_connect_test.ino:34:
C:\Users\varuramaprasad\Documents\Arduino\libraries\blynk-library-0.3.10\src/Adapters/BlynkSerial.h:73:10: note: void BlynkStream::begin(const char*, Stream&)
void begin(const char* auth, Stream& stream) {
^
C:\Users\varuramaprasad\Documents\Arduino\libraries\blynk-library-0.3.10\src/Adapters/BlynkSerial.h:73:10: note: candidate expects 2 arguments, 1 provided
F:\aa\Arduino_Serial_USB_connect_test\Arduino_Serial_USB_connect_test.ino: At global scope:
Arduino_Serial_USB_connect_test:83: error: expected unqualified-id before ‘for’
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
^
Arduino_Serial_USB_connect_test:83: error: ‘thisReading’ does not name a type
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
^
Arduino_Serial_USB_connect_test:83: error: ‘thisReading’ does not name a type
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
^
Arduino_Serial_USB_connect_test:86: error: expected declaration before ‘}’ token
}
^
Multiple libraries were found for “NewPing.h”
Used: C:\Users\varuramaprasad\Documents\Arduino\libraries\NewPing
Not used: C:\Program Files (x86)\Arduino\libraries\NewPing
Multiple libraries were found for “BlynkSimpleStream.h”
Used: C:\Users\varuramaprasad\Documents\Arduino\libraries\blynk-library-0.3.10
Not used: C:\Program Files (x86)\Arduino\libraries\Blynk
Not used: C:\Program Files (x86)\Arduino\libraries\Blynk
Not used: C:\Program Files (x86)\Arduino\libraries\Blynk
Not used: C:\Program Files (x86)\Arduino\libraries\Blynk
exit status 1
no matching function for call to ‘BlynkStream::begin(char [33])’
This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.