Help needed. Disable Pin Use for different function

Hi,

I am trying to "free" a pin for a function.

I am using an ESP32 Cam (Ai Thinker). The board uses pin 4 to power the onboard flash led. The board also uses the same pin as data line for the sd card. So when including the sd card library I cannot directly use the flash led by powering said pin.

My Question:
is there a way to completely deactivate the sd card to turn the flash on while taking a picture and then turn the sd card back on to write the buffer to file?

is there a way to completely deactivate the sd card to turn the flash on while taking a picture and then turn the sd card back on to write the buffer to file?

While the SD card's CS line is held HIGH, it's completely deactivated, so you can use that pin for anything you want. Remember that the LED might flicker though while you're writing to the SD card as the pin's output is reflected by the LED.

I was wondering if it is possible to completely disable the onboard flash LED without affecting the SD functions. My project doesn't need the LED at all but still uses the SD card read/write functions.
Will this work?:

void setup() {
pinMode(4,OUTPUT);
}

void loop() {
...
digitalWrite(4,LOW);
...
}

But once I tried it, and kept the pin @ LOW, the SD would not mount.
Is there a way around this?

There are a couple of pins on the esp family that at boot are temporary high and if I remember correctly I think D4 might be one of them, so pulling it low will crash the boot up. Do a search on usable pins for the esp. There is a ton of info relating to this out there

Hello Proietti,

Thank you for your reply.
It's not that I am looking for another pin to use.
I want to shut off the annoying light when the ESP32 is running.
If there is any other way to turn it off, please let me know.

I have sometimes just applied a black marker pen to the LED.

Ok first of when you say digitalWrite(4, LOW); What is 4. Is it GPIO4 or D4. They are not the same. ESP pin outs do not match the pin outs shown on the board.

Red LED: The Red LED on the board is used to indicate the power supply. It glows red when the board is powered.

Blue LED: The Blue LED on the board is connected to the GPIO pin. It can be turned on or off through programming. In some Chinese cloned boards like mine, this led might also be in red colour

So if I remember correctly GPIO2 is the on board blue led.

#define LedOn 2;

in the setup

pinMode (LedOn, OUTPUT);


Then in the loop

digitalWrite(LedOn, LOW);

If the SPI line to the SD card is the ENABLE, you can just move it to another GPIO and change the software to reflect the difference.