extruder filament sensor

Hi, i am new in this forum by the way sorry for my english.

I constructing filament extruder in marlin firmware like this LYMAN MULIER FILAMENT EXTRUDER V5 video 1 - YouTube , but i don't want to use lyman filament sensor Filament Width Sensor Prototype Version 3 by flipper - Thingiverse , the sensor which i want to use 3D filament meter caliper Arduino i2c tutorial that you think its good idea? lyman sensor use analog input, sensor that i want use digital, any one can help me with programming?

I was looking for finish code but didn't find it anywhere in Marlin-Mackerel-master arduino code >> pins.h need new pin like #define FILWIDTH_PIN_CLOCK X code >> temperature.cpp its sensor directory code keys word (current_raw_filwidth, FILWIDTH_PIN, current_filwidth, raw_filwidth_value) can any one help me with coding.

the code there you can download GitHub - filipmu/Marlin-Mackerel: Mackerel - A Version of Marlin for Lyman Extruders.

This is NOT the right place for getting help with Marlin firmware. See https://marlinfw.org/ or RepRap - RepRap.

way its NOT right place??? its arduino community and arduino coding how from analog(A5) input convert in digital pin. Analog input have one pin measure V, but how in the code include digital pin, digital pin have time micros(); function whether this would interfere with the code.

Caliper code:

#define CLOCK_PIN 12
#define DATA_PIN 11

void setup()
{
Serial.begin(9600);
pinMode(CLOCK_PIN, INPUT);
pinMode(DATA_PIN, INPUT);

}

char buf[20];
unsigned long tmpTime;
int sign;
int inches;
long value;
float result;
bool mm = true; //define mm to false if you want inces values

void loop()
{
while(digitalRead(CLOCK_PIN)==LOW) {}
tmpTime=micros();
while(digitalRead(CLOCK_PIN)==HIGH) {}
if((micros()-tmpTime)<500) return;
readCaliper();
buf[0]=’ ';
dtostrf(result,6,3,buf+1); strcat(buf," in “);
dtostrf(result*2.54,6,3,buf+1); strcat(buf,” cm ");

if(mm)
{
Serial.print(result); Serial.println(" mm");
delay(100);
}
else
{
Serial.print(result); Serial.println(" in");
delay(100);
}
}
void readCaliper()
{
sign=1;
value=0;
inches=0;
for(int i=0;i<24;i++) {
while(digitalRead(CLOCK_PIN)==LOW) {}
while(digitalRead(CLOCK_PIN)==HIGH) {}
if(digitalRead(DATA_PIN)==HIGH) {
if(i<20) value|=(1<<i);
if(i==20) sign=-1;
if(i==23) inches=1;
}
}
if(mm)
{
result=(valuesign)/100.0;
}
else
{
result=(value
sign)/(inches?2000.0:100.0); //We map the values for inches, define mm to false if you want inces values
}

}

By the way topic go from software to AUDIO topic?

@kestas

Language problem ?
Try a language closer to your native language: