ESP-32 cam GPIO error

I’ve been working on a project that utilized a buzzer and a PIR motion sensor interfaced with the esp-32 AI Thinker board. I wish to use the available GPIO pins to detect motion and turn on the buzzer but both pins keep outputting a logic state 1.

Is there anything I can do to prevent this output. I’ve tested a simple digitalWrite sketch which I’ll add below:

void setup (){
    pinMode(12, INPUT); //PIR sensor
    pinMode(13, OUTPUT); //buzzer
}

void loop (){
    int sensor = digitalRead(12);
    if (sensor == 1) {
        digitalWrite(13, HIGH);
      }
     else {
        digitalWrite(13, LOW);
      }
} //end loop

I’m using the GPIO pins 12 and 13 and I’m not utilizing the SD card reader on board.
Thanks.

Tried any of the other spare pins ?

Yes.....
I’ve also tried other pins but same result

As long as you do not have an sd card installed or the driver for it initialised then those gpio pins should be ok
although if gpio12 is high at startup it will prevent booting so prob. best using it as output

Are you sure the input pin is not being held high all the time?

BTW - I have a demo sketch for experimenting with the esp32cam module which may be of interest. It shows how to use an sd card in 1-bit mode which still allows you to use pins 12 and 13