tinkerspy / Automaton

Reactive State Machine Framework for Arduino
https://github.com/tinkerspy/Automaton/wiki
MIT License
369 stars 63 forks source link

Atm_led fails to turn off if using the level map feature #82

Open whittedb opened 3 years ago

whittedb commented 3 years ago

After attempting to implement an led using the level map and brightness features and the led failing to turn off, I looked at the code.

The logic in the action() ENT_OFF code path seems wrong to me unless I'm having a senior moment and missing something obvious. I believe the correct logic should be as follows.

if (activeLow) {
    digitalWrite(pin, HIGH);
} else {
    if (levelMapSize) {
        analogWrite(pin, 0);
    } else {
        digitalWrite(pin, LOW);
    }
}