LS Y201 JPEG camera and arduino

Hello people, When i run the following coding in IDE im getting the HEX outputs but its not ending that is im not getting the end of the pic message. Im getting endless HEX outputs. Is there any solution for this? Thanks!

#include <SoftwareSerial.h>

byte incomingbyte;

//Configure pin 2 and 3 as soft serial port
SoftwareSerial cameraSerial = SoftwareSerial(2, 3);

int a=0x0000, //Read Starting address
j=0,
k=0,
count=0;
uint8_t MH,ML;
boolean EndFlag=0;

void setup() {
Serial.begin(19200);
cameraSerial.begin(38400);

SendResetCmd();
delay(3000);
}

void loop() {
SendTakePhotoCmd();

Serial.println("Start pic");
delay(100);

while(cameraSerial.available()>0) {
incomingbyte=cameraSerial.read();
}
byte b[32];

while(!EndFlag) {
j=0;
k=0;
count=0;
SendReadDataCmd();

delay(75); //try going up
while(cameraSerial.available()>0) {
incomingbyte=cameraSerial.read();
k++;
if((k>5)&&(j<32)&&(!EndFlag)) {
b[j]=incomingbyte;
if((b[j-1]==0xFF)&&(b[j]==0xD9))
EndFlag=1;
j++;
count++;
}
}

for(j=0;j<count;j++) {
if(b[j]<0x10)
Serial.print("0");
Serial.print(b[j], HEX);
}
Serial.println();
}

delay(3000);
EndFlag = 0; // reset so that another picture can be taken
Serial.println("End of pic");
Serial.println();
}

//Send Reset command
void SendResetCmd() {
cameraSerial.write((byte)0x56);
cameraSerial.write((byte)0x00);
cameraSerial.write((byte)0x26);
cameraSerial.write((byte)0x00);
}

//Send take picture command
void SendTakePhotoCmd() {
cameraSerial.write((byte)0x56);
cameraSerial.write((byte)0x00);
cameraSerial.write((byte)0x36);
cameraSerial.write((byte)0x01);
cameraSerial.write((byte)0x00);

a = 0x0000; //reset so that another picture can taken
}

void FrameSize() {
cameraSerial.write((byte)0x56);
cameraSerial.write((byte)0x00);
cameraSerial.write((byte)0x34);
cameraSerial.write((byte)0x01);
cameraSerial.write((byte)0x00);
}

//Read data
void SendReadDataCmd() {
MH=a/0x100;
ML=a%0x100;

cameraSerial.write((byte)0x56);
cameraSerial.write((byte)0x00);
cameraSerial.write((byte)0x32);
cameraSerial.write((byte)0x0c);
cameraSerial.write((byte)0x00);
cameraSerial.write((byte)0x0a);
cameraSerial.write((byte)0x00);
cameraSerial.write((byte)0x00);
cameraSerial.write((byte)MH);
cameraSerial.write((byte)ML);
cameraSerial.write((byte)0x00);
cameraSerial.write((byte)0x00);
cameraSerial.write((byte)0x00);
cameraSerial.write((byte)0x20);
cameraSerial.write((byte)0x00);
cameraSerial.write((byte)0x0a);

a+=0x20;
}

void StopTakePhotoCmd() {
cameraSerial.write((byte)0x56);
cameraSerial.write((byte)0x00);
cameraSerial.write((byte)0x36);
cameraSerial.write((byte)0x01);
cameraSerial.write((byte)0x03);
}

sigh
[ code]
your code
[/ code]

how big is the picture file?
if you wait long enough you may see the end of the hex

Im waiting for more than a hour but still its not ending. The maximum size is 640x480.

I'm still waiting for you to put [ code] tags around your code so I can read it :slight_smile:

Hi

Did you ever get this to work?

Do you have the LS-Y201 IR jpeg ttl camera?