Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: blackheart on February 06, 2009, 06:19:53 PM

Title: Digital Pins vs. Analog Pins.
Post by: blackheart on February 06, 2009, 06:19:53 PM
A very basic forum search and an even lamer google search did not show much, so I will ask in here. What is(or are) the difference(s) between analog pins and digital pins. Analog for input and digital for output? I would also like(if possible) some information on which is best used where and why?


Also, I guess I would plug the servos in an unregulated power pin. That gets power from the attached battery. But what should be plugged in the 5V power pins? And where do they get the power from? a built-in little battery, or also from the main one, but they just get 5V?




Thank You!


Title: Re: Digital Pins vs. Analog Pins.
Post by: Canabots on February 06, 2009, 06:32:40 PM
Digital pins are either high or low. 0 or 1. Black or white. Light or dark. Nothing in between. They can be used as inputs AND outputs.
These are mostly for tactile or digital sensors, like buttons and switches. They are also used for motors and such (for your servos, for example).

Analog inputs is 0 and 1, with everything in between. Instead of just black and white, you can have dark grey, light grey, etc. These ARE ONLY inputs.

There's more info here about analog and digital: http://www.societyofrobots.com/microcontroller_tutorial.shtml (http://www.societyofrobots.com/microcontroller_tutorial.shtml)


Hope this clears thing up.  :)
Title: Re: Digital Pins vs. Analog Pins.
Post by: paulstreats on February 06, 2009, 06:34:54 PM
canabots just beat me to it... ;D
anyway i spent the time to wite this so here it is...

digital pins are both used for input/output (i/o). these work at the voltage level of the microcontroller so usually they can either output just 5v or just 0v. aswell they accept inputs of just 5v or just 0v (within tollerances).

analog ports are used to input a voltage that can be between 0v and 5v so a voltage of maybe 2.3v can be read with a microcontroller.

on the programming side, reading a digital port will produce eiter a 1 for 5v or 0 for 0v. reading an analogue port can produce a varying number. if the analog port is 8 bit then 0v will be read as 0 and 5v will be read as 255 any voltage level in between will produce a linear result on this scale so 2.5v would produce a reading of 127 on the programming side.

Quote
I would also like(if possible) some information on which is best used where and why?

it depends what you are using the port for. if you just want to turn a light on then use a digital port. if you want to read a sensor with a varying voltage then use an analog port. if you want to detect a push button switch then use a digital port.


Quote
But what should be plugged in the 5V power pins
5v power should come from a voltage regulator. first plug your batteries into the voltage regulator and then from the output of the regulator you get an even 5v (even if the battery is at 9v). this makes a stable power signal and stops 5v components from burning out. Also only plug the servos straight into atteries if you know that the batteries are 7.2v or below
Title: Re: Digital Pins vs. Analog Pins.
Post by: blackheart on February 06, 2009, 07:07:29 PM
I love you guys. You cleared things up for me. I still have some issues with volts and electricity stuff, but they should be solved really easy. Thank you again, I really love this place!
Title: Re: Digital Pins vs. Analog Pins.
Post by: householdutensils on February 06, 2009, 08:08:34 PM
These ARE ONLY inputs.

Are you sure? I'm sure I used the A/D pins as outputs on the ATMega8 a few days ago :S

Title: Re: Digital Pins vs. Analog Pins.
Post by: Webbot on February 06, 2009, 08:15:20 PM
Yes you can use the A/D pins as outputs. But Canabots said 'Analogue inputs' not the 'A/D pins'.
Title: Re: Digital Pins vs. Analog Pins.
Post by: householdutensils on February 06, 2009, 10:15:16 PM
Ahhhh I see. Sorry, I was a little confused  :P
Title: Re: Digital Pins vs. Analog Pins.
Post by: blackheart on February 08, 2009, 05:06:11 AM
How about pwm pins? they are on the digital side?
Title: Re: Digital Pins vs. Analog Pins.
Post by: paulstreats on February 08, 2009, 08:19:32 AM
pwm pins are i/o digital pins too. the difference with these is that these can also be used by the built in pwm module in the microcontroller. (you can do pwm on any pins in your programming but this takes a lot of the microcontrollers processing time. using the in built module with the designated pins will free up the processing time leaving it free to do other things)
Title: Re: Digital Pins vs. Analog Pins.
Post by: Joesavage1 on February 08, 2009, 09:08:53 AM
get the robot builders bonanza third edition, it covers many things like this =D

Joe