Inductive sensor

hello I need help with a inductive sensor to count parts work ok with arduino uno but I want to se the data in my phone
code for arduino uno

int ir_pin = 13;
int counter = 0;
int hitObject = false;
void setup() {
Serial.begin(9600);
pinMode(ir_pin,INPUT);
}
void loop() {
int val = digitalRead(ir_pin);
if( (val == 1) && (hitObject == false) ){
counter++;
hitObject = true;
Serial.print("Counter = ");
Serial.println( counter);
}else if( (val ==0) && (hitObject == true) ) {
hitObject = false;
}

}

/*************************************************************

code for ESP8266WiFI
************************************************************/
/
Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
int ir_pin = 13;
int counter = 0;
int hitObject = false;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “YourAuthToken”;
// Your WiFi credentials.
// Set password to “” for open networks.
char ssid[] = “YourNetworkName”;
char pass[] = “YourPassword”;
BlynkTimer timer;
// This function sends Arduino’s up time every second to Virtual Pin (5).
// In the app, Widget’s reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
// You can send any value at any time.
// Please don’t send more that 10 values per second.
Blynk.virtualWrite(V5, millis() / 1000);
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, “blynk-cloud.com”, 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
pinMode(ir_pin,INPUT);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
int val = digitalRead(ir_pin);
if( (val == 1) && (hitObject == false) ){
counter++;
hitObject = true;
Serial.print("Counter = ");
Serial.println( counter);
}else if( (val ==0) && (hitObject == true) ) {
hitObject = false;
}
}


but I not sure


BLYNK_READ(5) { // Usually, you will need to respond with a virtual pin value. Blynk.virtualWrite(5, some_value); }
how I can get the pin value number in this case 123456…

You may want to be more specific about what you want to do, what you have tried and what didnt work.

Also, you need to format your code properly to make it more readable:

the proyect is count parts with a inductive sensor and display the numbers with blynk app
the pin reads state, the sensor this high and add a number in sequence 1.2.3.4.5

As mentioned, please edit your post so that your code is formatted correctly. It is very hard to read as is.

How fast do the parts appear? Sounds like a good use for an interrupt routine.

Here is an example semi based off the Push Notification Button example on the Sketch Builder. It is Untested so no guarantees it will work, as I don’t use interrupts all to often. Also be aware of switch bounce, depending on how the sensor works this may or may not be a problem.

Display Widget on Virtual Pin 5

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  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
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.




 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

BlynkTimer timer;

int ir_pin = 13;
int resetPin = 12;
int counter = 0;

void notifyOnButtonPress()
{
counter++;
Serial.print("Counter = ");
Serial.println( counter);
Blynk.virtualWrite(V5, counter);
}

void resetCount()
{
if (digitalRead(resetPin) == LOW) 
    {
      counter = 0;
      Blynk.virtualWrite(V5, counter);
    }
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

    pinMode(resetPin, INPUT_PULLUP);

  // Setup notification button on pin 2
  pinMode(ir_pin, INPUT_PULLUP);
  // Attach pin 2 interrupt to our handler
  attachInterrupt(digitalPinToInterrupt(ir_pin), notifyOnButtonPress, RISING);

timer.setInterval(1000L, resetCount);
}

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

thank you I will try that

is working perfect

Awsome. Glad to hear.
Did you notice the rest button on pin 12? As written, ground it to reset the counter.

Yes thank you the reset work ok to