Eric Bryan and Patrick Whitley
Published

Arduino Digital Camera

Conversion of a Film Camera to Digital using an Adafruit TTL Serial Camera, Arduino Uno, 9v battery and a Sd breakout board.

BeginnerFull instructions provided1,724
Arduino Digital Camera

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Camera (generic)
×1
Flash Memory Card, MicroSD Card
Flash Memory Card, MicroSD Card
×1
SparkFun Level Shifting microSD Breakout
SparkFun Level Shifting microSD Breakout
×1
9V battery (generic)
9V battery (generic)
×1
Adafruit TTL Camera
×1
Pushbutton Switch, Momentary
Pushbutton Switch, Momentary
×1

Story

Read more

Schematics

Basic wiring Diagram

This is a wiring diagram with the poles labelled next to the camera module and SD board module

Wiring inside Camera

Back of Camera

Code

Camera8.ino

Arduino
Make sure to include the Correct libraries(Adafruit_VC0706,SPI,SD,and ezbutton)
// This is a (modified)basic snapshot sketch using the VC0706 library.
// Public domain.

#include <Adafruit_VC0706.h>
#include <SPI.h>
#include <SD.h>
#include <ezButton.h>
ezButton button(7);  // create ezButton object that attach to pin 7;
#if defined(__AVR__) || defined(ESP8266)

// On Uno: camera TX connected to pin 2, camera RX to pin 3:
#include <SoftwareSerial.h>         
SoftwareSerial cameraconnection(2, 3);

#else
#define cameraconnection Serial1

#endif

Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);


// SD card chip select line varies among boards/shields:
// Adafruit SD shields and modules: pin 10
#define chipSelect 10
void setup() {
     button.setDebounceTime(50); // set debounce time to 50 milliseconds
  // When using hardware SPI, the SS pin MUST be set to an
  // output (even if not connected or used).  If left as a
  // floating input w/SPI on, this can cause lockuppage.
#if !defined(SOFTWARE_SPI)
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  if(chipSelect != 53) pinMode(53, OUTPUT); // SS on Mega
#else
  if(chipSelect != 10) pinMode(10, OUTPUT); // SS on Uno, etc.
#endif
#endif

cam.begin();
Serial.begin(9600);
SD.begin(chipSelect);//begin sd card communication 
cam.setImageSize(VC0706_640x480); 


 
}
void loop() {

 button.loop(); // MUST call the loop() function first
 int runcam =0;
 if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
 }
  if (cam.begin()) {
    Serial.println("Camera Found:");
  } else {
    Serial.println("No camera found");
  }
 

  if(button.isPressed())
  {
     Serial.println("button pressed");
     runcam =1;
      
 
  
  if(runcam==1){
     delay(1000);
      Serial.println("runcam=1");  
     cam.takePicture();
  }


if(cam.takePicture()){
     delay(1000);
      Serial.println("pictaken");  
}
     


  
  
  // 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((uint16_t)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!");
  runcam = 0;
  if(runcam==0){
     delay(1000);
      Serial.println("runcam=0");  
     }
  
  }
}

Credits

Eric Bryan and Patrick Whitley

Eric Bryan and Patrick Whitley

1 project • 0 followers
Group design project for Mechanical Engineering

Comments