| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Social distancing? Try a better way to work remotely on your online files. Dokkio, a new product from PBworks, can help your team find, organize, and collaborate on your Drive, Gmail, Dropbox, Box, and Slack files. Sign up for free.

View
 

Koe Josephine Lab 5

Page history last edited by zahraa@... 4 years, 9 months ago

A3a. With the standard font, what is the longest message you can write across one line of the display? How many lines can you write?

 

With the standard font, each line is 14 characters long, and there are 6 lines.

 

A5a. Upload a photo of your personal logo, shown on your LCD screen, to your Lab 5 page.

 


 

 

B3a. Include the code that you had to insert to do this in your lab writeup.

 

I had to insert the following code before opening the file to read:

 

 File dataFile = SD.open("datalog.txt", FILE_WRITE); 

  if (dataFile) {

    dataFile.print(" He-Who-Must-Not-Be-Named.");

    dataFile.close();

  } 

 

 

B3b. 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 new file on the SD card with the added text on it first, then open the original file and copy its contents into the new file.

 

B3c. 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?

 

It wouldn't work if the file was larger than the memory, but what might work is copying the segment that would be overridden and storing that, then overriding it with the added content. Then the segment adjacent to the added content would be stored and replaced with the overridden contents. It would just continue like that until the end of the file.

 

Example:

 

File: 1111 2222 3333 4444 5555 6666 7777 8888 9999

 

Text to insert at the beginning: 0000

 

Store: 1111

 

Write: 0000 2222 3333 4444 5555...

 

Store: 2222

 

Write: 0000 1111 3333 4444 5555...

 

Store: 3333

 

Write: 0000 1111 2222 4444 5555...

 

....

 

Store: 8888

 

Write: ...6666 7777 9999

 

Store: 9999

 

Write: ...6666 7777 8888

 

Add: ...6666 7777 8888 9999

 

 

B4a. Post your code.

 

Koe Josephine Lab 5 Code

 

 

B5a. Tell us what you had to change to make this work.

 

I included the SD library instead of the EEPROM library and opened the file on the SD card for writing. Then, whenever I wrote to the EEPROM in my old code, I instead printed the data to the SD card file. Then I closed the file then opened it again for reading, and instead of reading from the EEPROM, I read from the file.

 

 

Da. Upload video of your Etch-a-Sketch in action!

 

https://www.youtube.com/watch?v=2U34MHbsBLs&feature=youtu.be

 

 

Comments (1)

xyyue@... said

at 2:11 pm on Aug 11, 2015

Well done.

You don't have permission to comment on this page.