digitalRead on pin 34.

harshcht
Posts: 5
Joined: Fri Mar 31, 2017 2:57 am

digitalRead on pin 34.

Postby harshcht » Mon Jun 05, 2017 11:40 am

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?

Thorvard
Posts: 2
Joined: Mon Feb 13, 2017 5:12 pm

Re: digitalRead on pin 34.

Postby Thorvard » Mon Jun 05, 2017 4:09 pm

GPIO 34-39 have no internal configurable pullup/down, you have to add a 10kohm resistor from the GPIO to 3,3V

harshcht
Posts: 5
Joined: Fri Mar 31, 2017 2:57 am

Re: digitalRead on pin 34.

Postby harshcht » Thu Jun 08, 2017 6:11 am

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));
        }

Who is online

Users browsing this forum: Bing [Bot] and 8 guests