Check if ATmega32u4 is defined

Needed in order to work with Arduino Leonardo
This commit is contained in:
Kristian Sloth Lauszus 2013-04-18 00:15:06 +02:00
parent 8d26462be2
commit 0a7b402c45
1 changed files with 3 additions and 0 deletions

View File

@ -42,6 +42,9 @@ int analogRead(uint8_t pin)
uint8_t low, high;
#if defined(analogPinToChannel)
#if defined(__AVR_ATmega32U4__)
if (pin >= 18) pin -= 18; // allow for channel or pin numbers
#endif
pin = analogPinToChannel(pin);
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
if (pin >= 54) pin -= 54; // allow for channel or pin numbers