1'''
2SDCard - Write to SD Card.py.
3
4This example demonstrates how to write messages into file.
5
6For other examples please check:
7 https://github.com/WPC-Systems-Ltd/WPC_Stand-alone_Python_release/tree/main/examples
8
9Copyright (c) 2024 WPC Systems Ltd.
10All rights reserved.
11'''
12
13import pywpc_sd
14
15## Initialize the SD card
16dev = pywpc_sd.SDCard()
17
18## Debug print SD card directory and files
19print(dev.getFileDirectory())
20
21## Create / Open a file in write mode.
22## Write mode creates a new file.
23## If already file exists. Then, it overwrites the file.
24dev.openFile("sample.txt","w")
25
26## Write sample text
27for i in range(20):
28 dev.writeFile("Sample text = %s\r\n" % i)
29
30## Close the file
31dev.closeFile()