Just starting out with Arduino and I cannot find any documentation that clearly explains how to simultaneously address an analog and digital pin with the same number. For example, take the provided AnalogWrite tutorial from the Arduino reference. The documentation is as follows.
int ledPin = 9; // LED connected to digital pin 9
int analogPin = 3; // potentiometer connected to analog pin 3
int val = 0; // variable to store the read value
pinMode(ledPin, OUTPUT); // sets the pin as output
val = analogRead(analogPin); // read the input pin
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
This all makes perfect sense to me, but say I wished to keep the potentiometer wiper attached to analog pin 3, but also connect the LED to digital pin 3. The global variables are merely assigned to a digit, but make no differentiation between analog and digital.
Thanks.Moderator edit: [code]
tags added. (Nick Gammon)