If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.
You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!
b. Explain what would you do differently to insert the same text string, but at the beginning of the file (without over-writing the current contents). You don't have to code this: just explain the process. If you're interested and have time make it work, show us your program.
I would create a temporary file and write the text string in the beginning. I would then copy over all of the text from the original file to follow the beginning string. I can then set the original file equal to the contents of the temporary file.
✔
c. Now tell us if your approach would work if the file were larger than your Arduino's memory (which is 2.5KB). If not, how could you work around that limitation?
My approach would not work with files larger than can be stored on the Arduino. A simple work around for this problem is to utilize the SD card and create the temporary file on the SD card.
✔
4. a. Post your code.
/*
SD card file dump
This example shows how to read a file from the SD card using the
SD library and send it over the serial port.
The circuit:
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 17 (listed on Micro as SS)
created 22 December 2010
by Limor Fried
modified 9 Apr 2012
by Tom Igoe
modified 1 May 2013
by Harry Johnson
This example code is in the public domain.
*/
#include <SPI.h>
#include <SD.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#define CONTRAST 50
//On the Arduino Micro, the SS pin is defined in software as pin 17.
5. a. Tell us what you had to change to make this work.
I had to change the include statements to be:
#include <SPI.h>
#include <SD.h>
I also needed to create a file on the SD card that I would use by saying SD.open("myFile.txt"); and then save it as a File object. Once I did this, I could replace every instance of EEPROM with my file variable. Lastly, I had to make a few slight changes to parameters of read and write functions and replace length with size.
Comments (1)
xyyue@... said
at 2:02 pm on Aug 11, 2015
Well done.
You don't have permission to comment on this page.