Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra time for LED on required #6

Open
ceewanna opened this issue Feb 26, 2024 · 0 comments
Open

Extra time for LED on required #6

ceewanna opened this issue Feb 26, 2024 · 0 comments

Comments

@ceewanna
Copy link

An extra 40 micro seconds (320-280) LED on time is probably required after taking reading from analogRead before it's turned off.

image

uint16_t GP2YDustSensor::readDustRawOnce(uint16_t waitMicroSecs)
{
    // Turn on the dust sensor LED by setting digital pin LOW.
    digitalWrite(this->ledOutputPin, LOW);

    // Wait 0.28ms before taking a reading of the output voltage as per spec.
    delayMicroseconds(waitMicroSecs);

    // Record the output voltage. This operation takes around 100 microseconds.
    uint16_t VoRaw = analogRead(this->analogReadPin);

    // Turn the dust sensor LED off by setting digital pin HIGH.
    digitalWrite(this->ledOutputPin, HIGH);

    return VoRaw;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant