Page 1 of 1

digitalRead on pin 34.

Posted: Mon Jun 05, 2017 11:40 am
by harshcht
I was trying to digital read (using arduino IDE) on my pin GPIO34 of esp32. However digitalRead(34), returns 0 irrespective of whether I press the button or not. I have connected the pin to 3.3 V sourse using a push button. Is there something I am doing wrong as the function works fine on pin 19 or any other pin but not on the pins with ADC. Is it that these pins cannot be used with digital read?

Re: digitalRead on pin 34.

Posted: Mon Jun 05, 2017 4:09 pm
by Thorvard
GPIO 34-39 have no internal configurable pullup/down, you have to add a 10kohm resistor from the GPIO to 3,3V

Re: digitalRead on pin 34.

Posted: Thu Jun 08, 2017 6:11 am
by harshcht
Thanks @thorvard Now it is working well with digitalRead however if I put in the following code.
It does not work properly and digitalRead gives zero even at 3.3 v analog input. Can I use both digital Read and analog read on the same pin?

Code: Select all

   void setup() {
       // put your setup code here, to run once:
       Serial.begin(112500);
       pinMode(34,INPUT);
      
      
       

     }

            void loop() {
      // put your main code here, to run repeatedly:
      //Serial.println("in loop");
       int a =0;
             for(int i=0;i<1000;i++)
      {
      a=a+ analogRead(34);
      }
       
         
         
        Serial.println(a/1000);
        
        Serial.println(digitalRead(34));
        }