Hello!
I’m doing a project whit an Arduino UNO, ArduCAM-F (without GLCD) and MT9D111 camera. I take a picture which is saved in a MicroSD.
When I’m trying to see the pictures at computer it only show me this kind of pictures
This code comes from ArduCAM’s page http://www.arducam.com/download/ but the code belongs to ArduCAM-LF wich has a GLCD, so I’m wondering if there is any differance that causes the problems.
This is the code I’m using:
#include <UTFT.h>
#include <SD.h>
#include <Wire.h>
#include <ArduCAM.h>
#include <avr/pgmspace.h>
const char bmp_header[54] PROGMEM =
{
0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
#define SD_CS 9
#define BMPIMAGEOFFSET 54
//UTFT(byte model, int RS, int WR, int RD, int CS)
UTFT myGLCD(ITDB32S,A2,A1,A0,10); // Remember to change the model parameter to suit your display module!
//ArduCAM(byte model,int RS, int WR, int RD, int CS)
ArduCAM myCAM(MT9D111,A2,A1,A0,A3);
void setup()
{
Wire.begin();
myCAM.write_reg(2, 0x00);
if (!SD.begin(SD_CS))
{
//while (1);
}
myCAM.InitCAM();
// Setup the LCD
myGLCD.InitLCD();
myCAM.write_reg( 0, 0x01);
}
void GrabImage(char* str)
{
File outFile;
char VH,VL;
int i,j = 0;
outFile = SD.open(str,FILE_WRITE);
if (! outFile)
return;
myCAM.write_reg( 2, 0x00); //Switch to MCU
myGLCD.resetXY(); //Reset the access location
myCAM.write_reg( 2, 0x02); //Switch to MCU Read
//Write the BMP header
for( i = 0; i < 54; i++)
{
char ch = pgm_read_byte(&bmp_header[i]);
outFile.write((uint8_t*)&ch,1);
}
//Reverse the BUS direction
DDRD = 0x00;
digitalWrite(10,LOW); //Assert the LCD CS
myGLCD.LCD_Read_Bus(&VH,&VL);
for(i = 0; i < 320; i++)
for(j = 0; j < 240; j++)
{
myGLCD.LCD_Read_Bus(&VH,&VL);
VL = (VH << 7) | ((VL & 0xC0) >> 1) | (VL & 0x1f);
VH = VH >> 1;
outFile.write(VL);
outFile.write(VH);
}
digitalWrite(10,HIGH); //Deassert the LCD CS
//myCAM.write_reg( 2, 0x01); //Switch to CAM
outFile.close();
return;
}
void loop()
{
char str[8];
static int k = 0;
uint8_t temp;
myCAM.write_reg( 2, 0x01); //Switch to CAM
while(1)
{
temp = myCAM.read_reg(0x81);
if(!(temp & 0x01)) //New Frame is coming
{
myCAM.write_reg( 2, 0x00); //Switch to MCU
myGLCD.resetXY();
myCAM.write_reg( 2, 0x01); //Switch to CAM
while(!(myCAM.read_reg( 0x81)&0x01)); //Wait for VSYNC is over
}
else if(temp & 0x02)
{
k = k + 1;
itoa(k, str, 10);
strcat(str,".bmp");
GrabImage(str);
//while(!(myCAM.read_reg( 0x81)&0x01)); //Wait for VSYNC is over
}
}
return;
}
It doesn’t send me error messages.
Greetings from México!