Hey people:
I've working with the arduino and a ttl cam (VCO 703) and I need to save the pictures to my computer -all the projects talk about save the pictures with a sd card, but I need to do it directly from the serial port to the computer-,I've been trying to do it writing the buffer of the picture to the serial port, but something is wrong because all that I see with the serial monitor are strange caracters, I'd appreciate if you can help me to know the way to save and see this type of data (jpg files) to the hard disk, the code that I've been editing is this:
#include <VC0706.h>
//#include <SD.h>
#if ARDUINO >= 100
#include <SoftwareSerial.h>
#else
#include <NewSoftSerial.h>
#endif
// This is the camera pin connection. Connect the camera TX
// to pin 4, camera RX to pin 5
#if ARDUINO >= 100
NewSoftSerial nss(4, 5);
#else
NewSoftSerial cameraconnection = NewSoftSerial(4, 5);
#endif
// pass the serial connection to the camera object
VC0706 cam = VC0706(&cameraconnection);
void setup() {
Serial.begin(38400);
Serial.println("VC0706 Camera test");
// Try to locate the camera
if (cam.begin()) {
Serial.println("Camera Found:");
} else {
Serial.println("No camera found?");
return;
}
// Print out the camera version information (optional)
char *reply = cam.getVersion();
if (reply == 0) {
Serial.print("Failed to get version");
} else {
Serial.println("-----------------");
Serial.print(reply);
Serial.println("-----------------");
}
// Set the picture size - you can choose one of 640x480, 320x240 or 160x120
// Remember that bigger pictures take longer to transmit!
//cam.setImageSize(VC0706_640x480); // biggest
cam.setImageSize(VC0706_320x240); // medium
//cam.setImageSize(VC0706_160x120); // small
// You can read the size back from the camera (optional, but maybe useful?)
uint8_t imgsize = cam.getImageSize();
Serial.print("Image size: ");
if (imgsize == VC0706_640x480) Serial.println("640x480");
if (imgsize == VC0706_320x240) Serial.println("320x240");
if (imgsize == VC0706_160x120) Serial.println("160x120");
// Motion detection system can alert you when the camera 'sees' motion!
cam.setMotionDetect(true); // turn it on
//cam.setMotionDetect(false); // turn it off (default)
// You can also verify whether motion detection is active!
cam.takePicture();
Serial.print("Motion detection is ");
if (cam.getMotionDetect())
Serial.println("ON");
else
Serial.println("OFF");
uint16_t jpglen = cam.frameLength();
Serial.print(jpglen, DEC);
Serial.println(" byte image");
while(jpglen !=0){
Serial.print(jpglen, DEC);
uint8_t *buffer;
uint8_t bytesToRead = min(64, jpglen);
buffer = cam.readPicture(bytesToRead);
Serial.write (buffer,bytesToRead); // Here I try to write the "image" data to the serial port
jpglen -= bytesToRead;
}
cam.resumeVideo();
Serial.print(jpglen, DEC);
Serial.println("byte image");
Serial.println("...Done!");
cam.setMotionDetect(true);
}
void loop () {
char filename[13];
strcpy(filename, "IMAGE00.JPG");
for (int i = 0; i < 100; i++) {
filename[5] = '0' + i/10;
filename[6] = '0' + i%10;
}
Serial.write(filename);
uint16_t jpglen = cam.frameLength();
Serial.print(jpglen, DEC);
Serial.println(" byte image");
Serial.print("Writing image to "); Serial.print(filename); // Here I pretend to write the name of the file to the serial port
}