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

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

Andrew J Dupree - Lab 5 Report

Page history last edited by Benjamin Tee 9 years, 1 month ago

Andrew J. Dupree

David Sirkin

EE47: Interactive Device Design

7/20/21

 

Lab 5: Etch-a-sketch Goodness

Part A

A: One can simply power the board and use a multimeter to check the voltage between Vcc and Gnd. I got 3.29V – good enough.

 

Part B

A: Each character is 7x5 pixels. That means you can write a message 16 characters long. Also one can write 6 lines of text.

B: I am having a tough time getting a good conversion from bitmap to my LCD. Starting with this:

Leads to

The inaccuracy could be due to contrast issues.

✔ I think it is a problem with the conversion. Try using a black and white only image.

Part C

 

2A: The Teensy uses SPI to talk to peripherals. In this way multiple devices can share a communication line, however only one (the intended) device will be on (at a time) when data is being sent. So there is no problem!

3A:

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

dataFile.write("\n He who must not be named!");

dataFile.close();

dataFile = SD.open("datalog.txt");

3B: An interesting question. Ostensibly, it seems the seek function is the answer to your problem. But putting the target memory address at position 0 is not sufficient, because one will overwrite the beginning of the current contents. To solve the problem, I would instantiate two new Strings. The first string would be the information wished to be added to the start of the file. I would copy the current contents of the file into the second string. I would then append the two strings together and write that into the file. Sloppy, but it should work.

✔ 

 

4A: This was challenging. I first tried using the Arduino String object. This made saving the data from the SD card filestream simple (string += for each byte read), but I quickly discovered that one could not print the String object to the graphical LCD using the provided function. Then I tried using a char* instead. However, moving data into the character pointer did not seem to work. I think deep copying and memory allocation would be necessary to pull this off (maybe). Finally I settled on keeping a simple character array the size of the graphical LCD (some 84 characters). I probably overthought this and am missing something simple.

 

char text[84];

if (dataFile) {

//string counter

int x = 0, y = 0;

while (dataFile.available()) {

sdIn = dataFile.read();

Serial.println(sd);

if(x < 84){

text[x] = sdIn;

x++;

}

//Serial.write(sdIn);

 

}

dataFile.close();

Serial.print(text);

}

 

Actually, a better  way to do this would simply be to open the file in WRITE mode, make sure the file pointer is seeking to the end of the file (it should, automatically, in write mode) and then write to the file.

✔ It automatically writes to the end of the file.

5A: Logging to the SD card would require changes (approximately) like these :

 

void log() {

int addr = 0;

while(logFlag == HIGH){

lcd.clear();

lcd.home();

lcd.print("logging ");

if(addr == 512){

addr == 0;

}

int val = analogRead(0)/4;

lcd.print(val);

 

File data = SD.open("log.txt", FILE_WRITE);

data.write(val);

data.close();

 

 

addr++;

delay(1000);

}

}

 

void read() {

int value;

for (int addr = 0; addr < 512; addr++){

 

File data = SD.open("log.txt");

value = data.read();

 

if(value > 75){

readFlag = LOW;

logFlag = LOW;

printFlag = HIGH;

violateFlag = HIGH;

break;

}

}

if(violateFlag == LOW){

readFlag = LOW;

logFlag = LOW;

printFlag = HIGH;

violateFlag = LOW;

}

}

Part D: Etch-a-Sketchin'

 

✔ Nice Demo! 

 

Comments (0)

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