aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Sloth Lauszus <lauszus@gmail.com>2013-04-18 00:15:06 +0200
committerKristian Sloth Lauszus <lauszus@gmail.com>2013-04-18 00:15:06 +0200
commit0a7b402c4524bf3483ccef3bfa70a6d6de97a912 (patch)
tree61389a4550ac277b9975f267c8cfc2d2d937d631
parent8d26462be25560182d05ab80ea106b239c0ee1cf (diff)
Check if ATmega32u4 is defined
Needed in order to work with Arduino Leonardo
-rw-r--r--cores/arduino/wiring_analog.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/cores/arduino/wiring_analog.c b/cores/arduino/wiring_analog.c
index 81fb1e1..a6b63e3 100644
--- a/cores/arduino/wiring_analog.c
+++ b/cores/arduino/wiring_analog.c
@@ -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