Moderators: adafruit_support_bill, adafruit
// Using SoftwareSerial (Arduino 1.0+) or NewSoftSerial (Arduino 0023 & prior):
//#if ARDUINO >= 100
// On Uno: camera TX connected to pin 2, camera RX to pin 3:
//SoftwareSerial cameraconnection = SoftwareSerial(2, 3);
// On Mega: camera TX connected to pin 69 (A15), camera RX to pin 3:
//SoftwareSerial cameraconnection = SoftwareSerial(69, 3);
//#else
//NewSoftSerial cameraconnection = NewSoftSerial(2, 3);
//#endif
#include <HardwareSerial.h>
HardwareSerial cameraconnection = Serial1; //'Serial1' is TX1/RX1 on a Mega. It is TX/RX on a Leonardo. On a Uno, use 'Serial'
Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection); // Try to locate the camera
if (cam.begin(115200)) {
Serial.println("Camera Found:");
} else {
Serial.println("No camera found?");
return;
}But if I don't include software serial library, the code doesn't compile..
#include <Adafruit_VC0706.h>
#include <SD.h>
#include <SoftwareSerial.h>
#include <HardwareSerial.h>
#define chipSelect 53
HardwareSerial cameraconnection = Serial1;
Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);
void setup() {
Serial.begin(9600);
Serial.println("VC0706 Camera snapshot test");
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
return;
}
if (cam.begin(115200)) {
Serial.println("Camera Found:");
} else {
Serial.println("No camera found?");
return;
}
char *reply = cam.getVersion();
if (reply == 0) {
Serial.print("Failed to get version");
} else {
Serial.println("-----------------");
Serial.print(reply);
Serial.println("-----------------");
}
cam.setImageSize(VC0706_160x120);
uint8_t imgsize = cam.getImageSize();
Serial.print("Image size: ");
if (imgsize == VC0706_160x120) Serial.println("160x120");
Serial.println("Snap in 3 secs...");
delay(3000);
if (! cam.takePicture())
Serial.println("Failed to snap!");
else
Serial.println("Picture taken!");
char filename[13];
strcpy(filename, "IMAGE00.JPG");
for (int i = 0; i < 100; i++) {
filename[5] = '0' + i/10;
filename[6] = '0' + i%10;
if (! SD.exists(filename)) {
break;
}
}
File imgFile = SD.open(filename, FILE_WRITE);
uint16_t jpglen = cam.frameLength();
Serial.print("Storing ");
Serial.print(jpglen, DEC);
Serial.print(" byte image.");
int32_t time = millis();
pinMode(8, OUTPUT);
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); // change 32 to 64 for a speedup but may not work with all setups!
buffer = cam.readPicture(bytesToRead);
imgFile.write(buffer, bytesToRead);
if(++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
Serial.print('.');
wCount = 0;
}
jpglen -= bytesToRead;
}
imgFile.close();
time = millis() - time;
Serial.println("done!");
Serial.print(time); Serial.println(" ms elapsed");
}
void loop() {
}
#include <Adafruit_VC0706.h>
#include <SD.h>
#include <SoftwareSerial.h>
#define chipSelect 53
Adafruit_VC0706 cam = Adafruit_VC0706(&Serial1);
You can also change the snapshot image dimension to 160x120, 320x240 or 640x480 by changing these lines:
// 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
cam.begin(115200);adafruit_support_rick wrote:The tutorial also explains how to change the image size:You can also change the snapshot image dimension to 160x120, 320x240 or 640x480 by changing these lines:
// 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 must specify the baudrate in cam.begin for anything other than 38400:
- Code: Select all
cam.begin(115200);
Users browsing this forum: No registered users and 8 guests