#include <Adafruit_VC0706.h>
#include <MemoryCard.h>
#include <SdFat.h>
#include <JPEGCamera.h>
#include <NewSoftSerial.h>
#include <MeetAndroid.h>
//Create an instance of the camera
JPEGCamera camera;
MeetAndroid meetAndroid;
//Create a character array to store the cameras response to commands
char response[32];
//Count is used to store the number of characters in the response string.
unsigned int count=0;
//Size will be set to the size of the jpeg image.
int size=0;
int c;
//This will keep track of the data address being read from the camera
int address=0;
//eof is a flag for the sketch to determine when the end of a file is detected
//while reading the file data from the camera.
int eof=0;
char *filePathImage = "/mduino/images/";
char val; // variable to receive data from the serial port(bluetooth)
void setup()
{
// You always need to initialise the MemoryCard library
Serial.println("Init MemoryCard...");
// This demonstrates making a directory hierarchy
Serial.println();
Serial.println("Make directory...");
MemoryCard.makeDir(filePathImage);
// You can check for the existence of specific files/directories
char *filePathImage = "/mduino/images/";
Serial.println();
Serial.print(filePathImage);
Serial.print(" does ");
if (MemoryCard.exists(filePathImage)) {
Serial.println("exist.");
} else {
Serial.println("not exist.");
}
//Setup the camera, serial port and memory card
camera.begin();
Serial.begin(57600);
}
void loop()
{
if(Serial.available())
{
val = Serial.read();
switch(val)
{
case 'a':
Serial.println("Take a picture!");
MemoryCard.begin();
//Reset the camera
count=camera.reset(response);
delay(3000);
//Set Image size
Serial.println("Set Image Size ");
//camera.setImageSize160x120(response);
//camera.setImageSize320x240(response);
//count = camera.setImageSize640x480(response);
Serial.write((const uint8_t*)response, count);
Serial.print(" Image Size =");
Serial.println(count);
delay(200);
//Reset the camera
count=camera.reset(response);
delay(3000);
//Take a picture
count=camera.takePicture(response);
//Print the response to the 'TAKE_PICTURE' command.
Serial.write((const uint8_t*)response, count);
Serial.println();
Serial.println("takePicture done! ");
//Get the size of the picture
count = camera.getSize(response, &size);
//Print the size
Serial.print("size=");
Serial.print(size);
//Create a file called 'test.txt' on the SD card.
//NOTE: The memoryCard libary can only create text files.
//The file has to be renamed to .jpg when copied to a computer.
MemoryCard.open("/image2.txt", true);
//Starting at address 0, keep reading data until we've read 'size' data.
while(address < size)
{
//Read the data starting at the current address.
count=camera.readData(response, address);
//Store all of the data that we read to the SD card
for(int i=0; i<count; i++){
//Check the response for the eof indicator (0xFF, 0xD9). If we find it, set the eof flag
if((response[i] == (char)0xD9) && (response[i-1]==(char)0xFF))eof=1;
//Save the data to the SD card
MemoryCard.file.print(response[i], BYTE);
Serial.print(response[i]);
//If we found the eof character, get out of this loop and stop reading data
if(eof==1)break;
}
//Increment the current address by the number of bytes we read
address+=count;
//Make sure we stop reading data if the eof flag is set.
if(eof==1)break;
}
MemoryCard.close();
MemoryCard.open("/image2.txt");
// // This approach is more compact
while((c = MemoryCard.file.read()) >= 0)
{
messageChar(1, c);
}
//Close the file
MemoryCard.close();
count = camera.stopPictures(response);
Serial.println("Done!");
break;
case 'f':
Serial.println("forward");
break;
default:
break;
}
}
}
Error message i get,
sketch_aug31a.cpp: In function 'void loop()':
sketch_aug31a:126: error: initializer expression list treated as compound expression
Now im getting this error
sketch_aug31a.cpp: In function 'void loop()':
sketch_aug31a:126: error: 'messageChar' was not declared in this scope
Now im getting this error
As in "I changed my code, but I don't want to post it again, and now..."?
Ashuk:
sketch_aug31a:126: error: initializer expression list treated as compound expression
Ashuk:
sketch_aug31a:126: error: 'messageChar' was not declared in this scope
Both error messages relate to messageChar(), which you call but don't declare or define anywhere in the code you have posted. What is this function?