diff --git a/esphome/components/uln2003/uln2003.cpp b/esphome/components/uln2003/uln2003.cpp index b1a397ad6c..38eadc9dc8 100644 --- a/esphome/components/uln2003/uln2003.cpp +++ b/esphome/components/uln2003/uln2003.cpp @@ -70,14 +70,8 @@ void ULN2003::write_step_(int32_t step) { } case ULN2003_STEP_MODE_HALF_STEP: { // A, AB, B, BC, C, CD, D, DA - if (i == 0 || i == 2 || i == 7) - res |= 1 << 0; - if (i == 1 || i == 2 || i == 3) - res |= 1 << 1; - if (i == 3 || i == 4 || i == 5) - res |= 1 << 2; - if (i == 5 || i == 6 || i == 7) - res |= 1 << 3; + res |= 1 << (i >> 1); + res |= 1 << (((i + 1) >> 1) & 0x3); break; } case ULN2003_STEP_MODE_WAVE_DRIVE: {