Analog input and PWM output pin numbers


I have an Arduino MEGA, and am using analog inputs 0-5 to read my sensors, and PWM outputs 2-13 to fade some lights. However, these pins share the same numbers! How can I differentiate them in my code so that I can use both analog inputs and PWM outputs with the same pin numbers?

thanks! /noha

There should be no conflict, the Arduino analog input function knows that analog input pins 0-15 are not the same pins as digital pins of the same number. By the way if you ever wish to use your analog input pins as additional digital pins (probably not with a Mega ;) ) you address them as digital pins 54-69, the Arduino core library does all the translation magic.


Ah, so it does.

Thank you, the issue I was seeing seems to have been caused by faulty wiring, of course.