SparkFun Electronics will be closed in observance of memorial day on Monday, May 29th. We will resume normal business hours on Tuesday, May 30th. Any orders placed after 2pm Mountain Time on Friday, May 26th will process and ship out on Tuesday, May 30th.

Junior Furini

Member Since: May 14, 2010

Country: Brazil




  • 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 ) {
    if ( readLine == 15 ) { break; }
    delay( 20 );
    In my case, 1 = white and 15 = black.

No public wish lists :(