I'm sure there's a very simple answer to this but I just can't seem to find it anywhere so forgive me if I'm asking a stupid question.
If for instance I want to set digital pin 5 as an output and analog pin 5 as an input using the pinMode command in setup, the Arduino seems to think they're the same pin on the board. How do I specify whether I want the analog or digital pin when they have the same number?
Here is a section of the code I've written-
int seg[] = {2, 3, 4, 5, 6, 7, 8};
int t = 0;
int potpin = 5;
long prevMillis = 0;
int count = 0;
the person stating pinMode doesn't work for analog input pins is correct the context of analog input, but it might be worth mentioning the following...
the analog pins 0-5 can also be used as digital pins 14-19
you can use digitalWrite to a set an input pin HIGH or LOW. This controls the pullup resistor on each pin.
this doesn't so much matter with regards to the problem experienced by the OP.
pinMode(seg[3], OUTPUT); // this sets digital pin 5 to output
...
pinMode(potpin, INPUT); // this sets digital pin 5 to input
so to recap,
a) analog inputs work as inputs automatically
b) pinMode is only for setting the mode of a DIGITAL pin
c) analog pins 0-5 can be used as digital pins 14-19
d) the pullup resistor of a digital input pin can be enabled/disabled by setting the input pin HIGH/LOW with digitalWrite