While I’m reading the documentation of GrovePi I understand when I use AnalogRead function the pin is always will be an AnalogPin. And if i use DigitalWrite always will be a DigitalPin. But how the grovepi library apart digital pins and analog pins in pinMode function?
Hey,
The pinMode does not affect the analog pins and only affects the digital pins. You can use pinMode to set the digital nature of the pin, i.e., whether the pin is digital input or output. The analog pins can work as digital I/O or analog inputs, but not analog output.
For example, you can give pinMode(1,OUTPUT), to make digital 1 output. The analog in, by default uses analog pin A1. So analogRead(1) reads from A1 pin and not D1. If you want to use A1 as a digital pin, then you’ll have to use the pin 15 for A1, digitalRead(15). These mappings are there by default in the Arduino IDE. These might be helpful too: http://www.arduino.cc/en/Tutorial/AnalogInputPins and http://marcusjenkins.com/wp-content/uploads/2014/06/ARDUINO_V2.png .