From 141276f1e76042dee403bcea13e84baca9f8e0a2 Mon Sep 17 00:00:00 2001 From: nelgi <46314439+nelgi@users.noreply.github.com> Date: Sun, 17 Nov 2019 12:44:32 +0200 Subject: [PATCH] Update IRSenderPWM.cpp Originally pins 44 and 45 did not work at all, and the data sent from pin 46 was different each time, plus the range was about 1-2cm. --- IRSenderPWM.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/IRSenderPWM.cpp b/IRSenderPWM.cpp index c935e74..5274ced 100644 --- a/IRSenderPWM.cpp +++ b/IRSenderPWM.cpp @@ -114,10 +114,12 @@ void IRSenderPWM::setFrequency(int frequency) // Fall-through to 46, timer 5 controls pins 44, 45 and 46 on Arduino Mega case 45: case 46: - TCCR5A = _BV(WGM51) | _BV(WGM50); + TCCR5A = _BV(WGM51); // This gives correct data from pins 44,45,46 and similar range to pin 9 TCCR5B = _BV(WGM53) | _BV(CS50); ICR5 = pwmval16; OCR5A = pwmval16 / 3; + OCR5B = pwmval16 / 3; // Also enable pin 45 + OCR5C = pwmval16 / 3; // Also enable pin 44 #else // Arduino Duemilanove etc #if !defined(__AVR_ATmega8__) @@ -264,4 +266,4 @@ void IRSenderPWM::space(int spaceLength) } } -#endif // ESP8266 \ No newline at end of file +#endif // ESP8266