Welcome to K210 Module repository
8.Memory card read and write files of the experiment
8 memory card reader experiment
8 memory card reader experiment 8.1 the experimental goals 8.2 experimental procedure 8.3 experimental results 8.4 the experiments are summarized
8.1 the experimental goals
This lesson is mainly for learning microPython memory card reader a picture of the function.
The present experiments the reference code path is: CanMV\03-Hardware\sdcard.py
8.2 experimental procedure
Module factory firmware has been integrated memory card control program, if you download the other firmware, please burn back to the factory firmware and then perform the experiment.
The first memory card inserted into the memory card slot on: as shown in the figure, the memory card Golden finger toward the screen, and then gently advance the card slot, hear the ‘click’ sound can let go, shows the insertion is successful.


If you need to remove the TF card, and then to gently press the TF card to hear the ‘click’ sound will be released, the TF card will automatically pop up card slot.
Initialize the LCD display and camera, the initialization after the completion of the print“init ok”.
lcd.init()sensor.reset()sensor.set_pixformat(sensor.RGB565)sensor.set_framesize(sensor.QVGA)sensor.run(1)sensor.skip_frames(10)print("init ok")
Create a picture saved path img_path
xxxxxxxxxximg_path = "/sd/image-1.jpg"
Open camera to capture a frame of image, save as img and img is saved to the memory card, the name for the
image-1.jpgit.
xxxxxxxxxximg = sensor.snapshot()print("save image")img.save(img_path)
Will
image-1.jpgFrom the memory card reader out, and on the LCD display.
xxxxxxxxxxprint("read image")img_read = image.Image(img_path)lcd.display(img_read)print("ok")
8.3 experimental results
Connect the K210 module to the computer through the microUSB data cable, CanMV IDE click the connect button, after the connection is completed click the Run button to run the routine code. You can also download the code as main.py and run it in the K210 module.
The system initializes the camera and the display after shooting a picture and save it to the memory card, and then the image is read out of the display to the LCD screen.

If you do not insert the memory card, the system will be unable to save pictures and error.

If the memory card using a card reader connected to a computer, you can see in the memory card root directory adds a image-1.jpgFile

8.4 the experiments are summarized
Use CanMV IDE, with the factory firmware write a good MicroPython syntax, memory card, internal integration and initialization, no additional initialization operations. Before performing the experiment you need to first insert a memory card into the memory card slot, otherwise it will error.
Due to the K210 read and write memory card compatibility is limited, some memory cards may not read and write problems, such as unable to read and write problems, please re-for a memory card used.