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.
This commit is contained in:
nelgi 2019-11-17 12:44:32 +02:00 committed by GitHub
parent 8943bf388d
commit 141276f1e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -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
#endif // ESP8266