Adafruit TTL Camera not Taking Image

Hello! I have wired up an Adafruit mini-ttl camera to my Arduino Mega.
When I run the “take snapshot” example, it works perfectly- and an image is saved to a SD card.

However, I’m trying to make the camera take a picture, in a larger, different program. (Add picture capability to my robot)

The camera is detected in the other program, but the actual picture taking is done in the “Pic()” function. When I call the “Pic()” function, the TTL Camera is unable to take a photo.

Here is the Pic() Function: (I just copied from the “Take Snapshot” example sketch. I could’ve easily missed something important)

void Pic() {
Serial.println("Snap in 3 secs...");
  delay(3000);

  if (! cam.takePicture())  {
    Serial.println("Failed to snap!");
  }
  else {
    Serial.println("Picture taken!");
  
  // Create an image with the name IMAGExx.JPG
  char filename[13];
  strcpy(filename, "IMAGE00.JPG");
  for (int i = 0; i < 100; i++) {
    filename[5] = '0' + i/10;
    filename[6] = '0' + i%10;
    // create if does not exist, do not open existing, write, sync after write
    if (! SD.exists(filename)) {
      break;
    }
  }
  
  // Open the file for writing
  File imgFile = SD.open(filename, FILE_WRITE);

  // Get the size of the image (frame) taken  
  uint16_t jpglen = cam.frameLength();
  Serial.print("Storing ");
  Serial.print(jpglen, DEC);
  Serial.print(" byte image.");

  int32_t time = millis();
  pinMode(8, OUTPUT);
  // Read all the data up to # bytes!
  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;
    }
    //Serial.print("Read ");  Serial.print(bytesToRead, DEC); Serial.println(" bytes");
    jpglen -= bytesToRead;
  }
  imgFile.close();

  time = millis() - time;
  Serial.println("done!");
  Serial.print(time); Serial.println(" ms elapsed");
}
}

SQ

I could’ve easily missed something important

Like, your code, perhaps?

AWOL: Like, your code, perhaps?

I posted my code... If you mean stuff outside of the Pic function - there isn't really much that pertains to the camera. Simply the initialization of the camera. (As I said, the camera is FOUND by the program, so I assume that initialization is working) The only part that fails is when the Pic() function is called. The Serial Monitor always says "Failed to snap" when it's called.

stupid-questions: I posted my code...

sp. "I posted my snippet"

AWOL:
sp. “I posted my snippet”

These are the ONLY other parts of the code that have anything to do with the camera:

DECLARE CAMERA OBJECT: (Before the Setup)

//--------PHOTOGRAPHY---------
SoftwareSerial cameraconnection = SoftwareSerial(69, 3);

Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);

INITIALIZE THE CAMERA: (During the Setup)

cam.setImageSize(VC0706_320x240);        // medium
  if (cam.begin()) {
    Serial.println("Camera Found:");
  } else {
    Serial.println("No camera found?");
  }

After that, there’s just the Pic() function which I posted already.

No setup()? No loop()?

(I'm not a patient person, and I'll get bored soon, so I'll stop bugging you) )

AWOL: No setup()? No loop()?

(I'm not a patient person, and I'll get bored soon, so I'll stop bugging you) )

The wider program that I am trying to implement this camera into is quite long, with a bunch of unrelated stuff. (Bluetooth, HCSR04, EMIC2, Pixy Camera, Servos, etc)

I have posted to you the ONLY elements of the program that have anything to do with this camera module. The library is included, as well as the SD library. The SD card initializes correctly.

I really don't think you need (or want) to look at all that other junk code, if this is the only thing to do with the camera.

AWOL: No setup()? No loop()?

(I'm not a patient person, and I'll get bored soon, so I'll stop bugging you) )

After scanning my code I have discovered the problem. My code incorperates an EMIC2 text-to-speech module. In the setup, I have

emic.begin(EmicrxPin,  EmictxPin);

When this line is removed, the picture is taken correctly. When this line is in the program, I get the "Failed to Snap" Error. Why would the Emic 2 be interfering with the camera???

(Apologies for not posting the whole program. I just don't want to bog everyone down with this huge sketch that would be hard to manage/post in the first place)

Why would the Emic 2 be interfering with the camera???

How the Hell do I know? You didn't post your code (I may already have mentioned this)

AWOL: How the Hell do I know? You didn't post your code (I may already have mentioned this)

As outlined in a post of Robin's, he states that two SoftwareSerial ports are not practical. I will try to free up a Hardware Serial port to make this work.