| 
  • 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
 

EE47 Lab 5: Etch-a-Sketch

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

Neil Barot

Home Lab: Monday OHs 

Lab 5

 

Part A. Graphical LCD

 

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

On each line, you can write 14 characters. You can write on up to 6 lines. An example of the longest message that can be written across one line of the display would be "Fourteen chars" as that sentence has 14 characters. 

 

 

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

 

 

Part B. microSD Card

 

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

 

3b. 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).

To insert the same text string at the beginning of the file without over-writing the current contents, you need to:

  1. Create a new string variable with the same text string being it's contents. 
  2. Open up the file you wish to add this to the beginning of.
  3. Begin reading from the file and appending that information to the new string variable until EOF char.
  4. Wipe the file.
  5. Write the new string variable to the file. 

 

3c. 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 be similar to what I mentioned earlier, except after about 2KB, I would create a new file and append the string to this new file. I would continue to do this until reaching the EOF char, after which, instead of wiping the initial file, I would store its file name, delete the file, and rename the new file to the stored file name, thereby replacing the old one and working around the limitation.

 

 

4a. Post your code.

 

 

5a. Tell us what you had to change to make this work.

I made a tone logger, so I simply had to change my readEEPROM() and writeEEPROM() functions to work with SD instead. For the writeEEPROM(), instead of using EEPROM.put(), I just opened the file with write permissions, used dataFile.write() with the same information as I would in EEPROM, and close the file. A key thing to note is that I used '/n/ characters to indicate where my values stopped and started as I did not write to specific memory addresses. For readEEPROM(), instead of using EEPROM.get(), I used dataFile.read(), while checking for '/n' chars. At each '/n' char, I'd close the string and push it onto an array of strings. This allowed me to split the numbers and access them the same way I did with EEPROM. I used the toInt() function to convert my strings to ints, and sure enough, it worked exactly the same!

 

 

Part D. Create an Etch-a-Sketch!

 

 

 

 

 

 

 

 

 

 

Comments (1)

xyyue@... said

at 1:58 pm on Aug 11, 2015

Well done.

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