The only line I really changed is Serial.write(buffer, bytesToRead); to receive the jpeg on my computer instead of in the SD card.
Here is the code I tried to use:
Code: Select all
#include <Adafruit_VC0706.h>
#include <SoftwareSerial.h>
SoftwareSerial cameraconnection = SoftwareSerial(2, 3);
Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);
void setup() {
Serial.begin(38400);
Serial.println("VC0706 Camera snapshot 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("-----------------");
}
cam.setImageSize(VC0706_640x480);
Serial.println("Snap in 3 secs...");
delay(3000);
if (! cam.takePicture())
Serial.println("Failed to snap!");
else
Serial.println("Picture taken!");
uint16_t jpglen = cam.frameLength();
Serial.print("Storing ");
Serial.print(jpglen, DEC);
Serial.println(" byte image.");
Serial.println("-----------------");
int32_t time = millis();
byte wCount = 0; // For counting # of writes
while (jpglen > 0) {
// read 32 bytes at a time;
uint8_t *buffer;
uint8_t bytesToRead = min(32, jpglen);
buffer = cam.readPicture(bytesToRead);
Serial.write(buffer, bytesToRead);
jpglen -= bytesToRead;
}
time = millis() - time;
Serial.println();
Serial.println("-----------------");
Serial.println("Done!");
Serial.println("-----------------");
Serial.print(time); Serial.println(" ms elapsed");
}
void loop() {
}