From 03d5e6d10429883f420328bf38cb73720ba8e885 Mon Sep 17 00:00:00 2001 From: Tomas kovacik Date: Tue, 17 Aug 2021 19:54:38 +0200 Subject: [PATCH] support for longer pulses, as delayMicroseconds can wait only 16383us (https://www.arduino.cc/reference/en/language/functions/time/delaymicroseconds/) --- RCSwitch.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/RCSwitch.cpp b/RCSwitch.cpp index 99d3cc1..b5cea60 100644 --- a/RCSwitch.cpp +++ b/RCSwitch.cpp @@ -536,9 +536,11 @@ void RCSwitch::transmit(HighLow pulses) { uint8_t secondLogicLevel = (this->protocol.invertedSignal) ? HIGH : LOW; digitalWrite(this->nTransmitterPin, firstLogicLevel); - delayMicroseconds( this->protocol.pulseLength * pulses.high); + delay((this->protocol.pulseLength * pulses.high)/1000); + delayMicroseconds((this->protocol.pulseLength * pulses.high)%1000); digitalWrite(this->nTransmitterPin, secondLogicLevel); - delayMicroseconds( this->protocol.pulseLength * pulses.low); + delay((this->protocol.pulseLength * pulses.low)/1000); + delayMicroseconds((this->protocol.pulseLength * pulses.low)%1000); }