Author Topic: Digital Pins vs. Analog Pins.  (Read 6844 times)

0 Members and 1 Guest are viewing this topic.

Offline blackheartTopic starter

  • Full Member
  • ***
  • Posts: 111
  • Helpful? 1
Digital Pins vs. Analog Pins.
« 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!


I'm out of ideas!

Offline Canabots

  • Contest Winner
  • Robot Overlord
  • ****
  • Posts: 245
  • Helpful? 6
  • It's not a bug, it's a feature!
Re: Digital Pins vs. Analog Pins.
« Reply #1 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


Hope this clears thing up.  :)
« Last Edit: February 06, 2009, 06:40:10 PM by Canabots »
My robotics, electronics, software, or other stuff blog:
www.saltech.wordpress.com

Offline paulstreats

  • Supreme Robot
  • *****
  • Posts: 1,381
  • Helpful? 21
Re: Digital Pins vs. Analog Pins.
« Reply #2 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
« Last Edit: February 06, 2009, 06:36:17 PM by paulstreats »

Offline blackheartTopic starter

  • Full Member
  • ***
  • Posts: 111
  • Helpful? 1
Re: Digital Pins vs. Analog Pins.
« Reply #3 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!
I'm out of ideas!

Offline householdutensils

  • Full Member
  • ***
  • Posts: 72
  • Helpful? 2
Re: Digital Pins vs. Analog Pins.
« Reply #4 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


Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,150
  • Helpful? 109
Re: Digital Pins vs. Analog Pins.
« Reply #5 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'.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline householdutensils

  • Full Member
  • ***
  • Posts: 72
  • Helpful? 2
Re: Digital Pins vs. Analog Pins.
« Reply #6 on: February 06, 2009, 10:15:16 PM »
Ahhhh I see. Sorry, I was a little confused  :P

Offline blackheartTopic starter

  • Full Member
  • ***
  • Posts: 111
  • Helpful? 1
Re: Digital Pins vs. Analog Pins.
« Reply #7 on: February 08, 2009, 05:06:11 AM »
How about pwm pins? they are on the digital side?
I'm out of ideas!

Offline paulstreats

  • Supreme Robot
  • *****
  • Posts: 1,381
  • Helpful? 21
Re: Digital Pins vs. Analog Pins.
« Reply #8 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)

Offline Joesavage1

  • Robot Overlord
  • ****
  • Posts: 268
  • Helpful? 0
Re: Digital Pins vs. Analog Pins.
« Reply #9 on: February 08, 2009, 09:08:53 AM »
get the robot builders bonanza third edition, it covers many things like this =D

Joe

 


Get Your Ad Here