Junior Furini

Member Since: May 14, 2010

Country: Brazil

Profile

Websites

juniorfurini.com

  • Product ROB-09454 | about 4 years ago

    Hi.
    I had a some problem that you.
    pulsein is good, but for me it had a problem with timeout. When sensor get a black floor, pulsein didn’t return any value and “void loop()” was freezed waiting for value.
    Now I used the code below:
    pinMode( pinLine, OUTPUT );
    digitalWrite( pinLine, HIGH );
    delayMicroseconds( 50 );
    pinMode( pinLine, INPUT );
    // long readLine = pulseIn( pinLine, HIGH, 1000000L ); // wait max for 1 second.
    long readLine = 0;
    while ( digitalRead( pinLine ) == HIGH ) {
    readLine++;
    if ( readLine == 15 ) { break; }
    delay( 20 );
    }
    In my case, 1 = white and 15 = black.

No public wish lists :(