I've never created an Arduino project before and have a question about the analog and digital pis. I plan to use both the analog pins and the digital pins and noticed that they use the same numbers. I mean there are Analog pins 0-5 and Digital pins 0-13....what if I want to use BOTH analog pin 3 and digital pin 3?
Do I need to specify what type of pin (port) in my pin assignments or does the Arduino software just sort of....figure it out?
analogWrite(2,255) will light up DIGITAL pin 2 at full brightness (continous on). analogWrite is confusing because it ALWAYS writes to a DIGITAL pin!
analogRead(2) works as expected, reading analog pin 2 , while digitalRead(2) reads digital pin 2 (provided you call pinMode(2,INPUT) first.)
[edit]To turn on the LED on analog pin 2, as Osgeld mentioned, you need to refer to it as digital pin 16:
pinMode(16,OUTPUT);
digitalWrite(16,HIGH);[/edit]
I thought anlogWrite() only worked on the PWM pins. If that is true then doing an analogWrite() to digital pin 2 would have no effect.
On most Arduino boards (those with the ATmega168 or ATmega328), this function works on pins 3, 5, 6, 9, 10, and 11.
Keep in mind the analog pins are read only unless they have been designated as digital pins by using digitalWrite(14, xxx), digitalWrite(15, xxx) and so on.
Thanks, I think that's a little more clear now. To save myself from further confusion I think I will go ahead and use the true pin numbers in my program (14-19). Weird that this isn't an FAQ question lol.