Creating Folder and Storing multiple images in the same folder

Hey there,
I am trying to create folders and storing multiple images in that using digital IO. The folders are getting created but only 1 image is getting stored.
What exactly I want to do is:

  1. If I press button 1: Create a new folder (Folder_1)
  2. If I press button 2: Click an image and store in folder last created (Folder_1)
  3. If I press button 1 again: Create a new folder (Folder_2)

This loop goes on, but this is happening without me pressing the button. I have tried all permutations and combinations I could think of. Please guide me on this.

The configurations are as follow:
I have pulled the switch connected on both pins as HIGH when it is closed.

  pin0 = Pin('P0', Pin.IN, Pin.PULL_DOWN)
  pin1 = Pin('P1', Pin.IN, Pin.PULL_DOWN)
     
  button1 = pin0.value()
  button2 = pin1.value()
 
  if (button1 == 1)
      __________

  if (button2 == 1)
      __________

Any kind of help will be appreciated. Thanks in advance!

Hi, you need to give me a complete code snippet that produces the error.

I can’t really tell from what you have posted above. Typical issues for this kind of behavior are coding mistakes.