-2

I need to have two independent arduino sd libraries so that I can modify one and have the other one intact. I struggle to do so. Does anyone know if this is even possible? What should be the path to properly do so?

I tried a lot of things but I always end up in a spot where I dont know what code is working and what is not. Last try I duplicated all the files and renambed all the functions to whatever"2" but couldn't make it work

9
  • 1
    What is the background of your project? Do you want to use both libraries in the same sketch? If so, why? What requirements do you have? Please edit your question and add these informations, don't use comments. Commented Aug 2, 2022 at 6:07
  • Do you need to use both of them insifde the same project?
    – Tomas
    Commented Aug 2, 2022 at 12:01
  • If not then just create the library folder and copy it within the project where you are editing it Then include it as #include "Sd.h" rather then #include "Sd.h"
    – Tomas
    Commented Aug 2, 2022 at 12:04
  • Yes I need to use them both inside the same project
    – Espada86
    Commented Aug 2, 2022 at 13:11
  • 1
    If your objective is to use 2 SD card readers (pseudo) simultaneously in a project then this may help: forum.arduino.cc/t/two-sd-cards-on-the-same-project/1012605
    – 6v6gt
    Commented Aug 3, 2022 at 2:53

1 Answer 1

1

If you want to use two SD card than instead of copying the whole library just create another instance of the class like

SDClass SD2;

Now you can call SD2.begin(CS_PIN_2) or any other function of the sd library.

6
  • That wont work because you are using the same library just changing the name where you call it. I need two independent libraries
    – Espada86
    Commented Aug 2, 2022 at 13:12
  • Why do you need two independent libraries? Are you aware that the variables of both objects of SDClass are already independent? Commented Aug 3, 2022 at 5:53
  • @Espada86 Why you want two libraries? Because you want to use two SD cards ?
    – Arslan
    Commented Aug 3, 2022 at 6:45
  • @the-busybee the requierement is to have two independent libraries because I want to modify one and have the other one unchanged but being able to call any of them on the same sketch.
    – Espada86
    Commented Aug 3, 2022 at 7:20
  • @Espada86 Can you give a hint what you want to change in the library ?
    – Arslan
    Commented Aug 3, 2022 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.