module 2-4: writing our first programs akiba -freaklabs
TRANSCRIPT
• Module 2-4: Writing Our First Programs
• Akiba - FreakLabs
MODULE 3-5Reading and Writing to the SD card
Lab 5B: Did I Just Create MS-DOS?
Goals
• Create a command to write a sensor reading to a file
• Create a command to read the sensor reading from a file
• Create a command to delete a file
• Create a command to list out all the files in the directory
Why Is This Important?
• Build more familiarity with the file system and file operations
• Quicker and easier to write, read and test our code through the command line
• Most important - test out critical part of our data logger functionality!
What Do I Need to Know?
• myFile.write()
• myFile.read()
PLUS
• sd.ls()• Lists all the files in a directory
• sd.remove(filename)• Removes a file called filename from the sd card.
Writing the Code
Code continues on next page. …
Writing the Code
•
Code continues on next page. …
Writing the Code
•
Writing the Code
•
Don’t forget to check the new line is set to carriage return and the baud rate is 57600
Writing the Code
• fwrite filename = writes a sensor reading to the specified file name
• fread filename = reads the data in the specified file
Writing the Code
• ls = lists the files in the directory
• rm = deletes the specified file from the sd card
MODULE 3-5Reading and Writing to the SD card
Lab 5C: Did I Just Create a Data
Logger?