How should i determine whether to use input as analog or digital and same for output too?

  • This question is too general. Rather mention the specific problem you want to solve, in which you cannot find a way to decide between analog Vs. digital. – jfpoilpret Mar 11 '17 at 9:37
  • I am making an line follower robot so i am unable to understand what to use analog or digital pins. – Ankush Rawat Mar 11 '17 at 9:48
  • You also need to specify what sensors you are using for your line following robot. – jfpoilpret Mar 11 '17 at 9:49
  • 1
    There must be over 10000 different sensors of this kind. Put exact references please. References will lead you to datasheets, datasheets will lead you to the solution: either they provide an analog signal or a digital one! – jfpoilpret Mar 11 '17 at 9:53
  • 1
    Then I'm afraid you don't know enough to build your robot. You have a lot to learn first. – jfpoilpret Mar 11 '17 at 9:58

You will use digital pin modes when dealing with signals that are either "on" or "off", such as an LED, a switch, or another digital IC.

Analog inputs are used when you want to read the voltage potential of something. This is typically used to read analog sensors. Analog outputs are not really analog at all on the Arduino. Instead, the Arduino uses something called PWM to create a pseudo-analog signal.

You can read more about analog and digital here: https://learn.sparkfun.com/tutorials/analog-vs-digital

| improve this answer | |
  • Is it same for output too – Ankush Rawat Mar 9 '17 at 5:03
  • 1
    For digital? Yes. Digital input and output are the same. Analog input is different from analog output. Analog in uses special hardware to determine a the voltage on the pin, while analog output uses PWM to mimic a voltage on the pin, but it is not truly analog out. – woo2 Mar 9 '17 at 5:07
  • 1
    Also note that the analog pins can also be used as digital input and digital outputs. In case you run out of pins. – Gerben Mar 9 '17 at 9:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.