I am a beginner. Need some answers...Please help!!

Its only been 2 weeks since i have been starting to learn about arduino (through tutorials). After trying my hand at writing some sketches, some of these questions have been blocking my mind. I couldnt find the answers to any of these in the tutorials. please help me :-[- i have seen in many example sketches that to assign a pin to a variable, programmers use 'int mypin = 0;'(alotting pin 0 to variable mypin, say) and for initialising a variable, they use 'int myvalue = 0;'(say). if both these statements are written in the same sketch then how would the compiler differentiate between a pin assignment and a variable assignment statement since both are exactly alike?

  • if i am to use the digital pin '0' along with the 'analog in' pin '0' as input pins in a sketch for some reason, how would the compiler differentiate between which of these pins to be used for a digital input and which of them for an analoge input, considering the pin defining statements and the serial no. of the pins are exactly alike? would it differentiate through the read statements that follow these pins later in the sketch?

  • can analog input pins from 0 to5 be read for digital values using digitalRead command and vice-versa?

  • can we configure any of the digital pins from 0 to 13 as analog input pins in case we need to interface more than 6 analog sensors?

In your first question you're only assigning a name or alias of the pin to the variable, not the value on the pin itself. You give the alias to a read or write function which does the actual I/O in the pin.

yes you can make the analogue pins into digital pins, but not vice versa.

answer to #2:

the analogPins are actually addressed as 14-19 (i guess)... well... just the next consecutive number after your last digitalPin. read the doc of the board to know exactly how to address the analogPins. this is kind of a trap that noobs (like me, also) sometimes stumble upon.

a little hint: if you do not need all your digitalPins on the arduinoBoard, then try not to use digital pins {0,1,13}. 0 and 1 are used for communication. if you have your circuitry set up and want to upload a new sketch, then you must disconnect pins 0 and 1. that is no problem, but sometimes if you apply too much force or whatever, other cables get disconnected and stuff. bugfixing can then become a pain in the ass because you are searching in the wrong place.

as to pin 13... this pin has its internal pull-up-resistor enabled. read it up in the docs to know what it means. if you do not take special precautions and want to connect a LED or whatever, chances are that your LED does not quite work the way you expect it to. there is no harm done, however, but it might or might not shine or blink or whatever you want it to do, though your code seems ok. it is a hardware design thing you must know of in order to be able to use pin 13 the way you got accustomed to using the other pins.

since you now know the "spookyness" of pin 13, you are hereby granted the title: ensign of arduinoNoobness!

kind regards

ps: excuse me inglis! me not native speaker of lingua franca del sciencia.

thanks edm.....

as to pin 13... this pin has its internal pull-up-resistor enabled

Anyone else know anything about this?

you'll be fine after a couple of weeks when you really start to understand things