Serial Camera Module Programming Instructions and Tutorial PDF
Serial Camera Module Programming Instructions and Tutorial PDF
Tips:
1)How to assemble picture file from data packages:
To assemble the data from the package, u have to remove the 4 byte
header (at beginning of dat package) + 2 byte trailer (at the end of data
package) and concatenate all these from all the package sequentially one
after another.
2) Video Mode:
Just do not send SNAPSHOT command, the camera is effectively running
in video mode, you just send GET_PICTURE as quickly as you can.
3)"Set Package Size" command must be sent from host to CAM - before
"SNAPSHOT" command, which capture the image from the camera into the
CAM memory buffer.
4) How Camera works: The camera creates an image in the buffer. Now, if
you send the snapshot command, camera builds the image in the buffer but
doesn't send it. You can send Get Picture command (with snapshot picture
option set) to get that picture from the buffer. The snapshot remains in the
buffer until you take a new snapshot or new JPEG/Raw picture though Get
Future Electronics Egypt Ltd. (Arduino Egypt).
Picture command. The picture also remains in the memory buffer as long
as you have power connected to it.
Once you have got the data you can view the image, which depends on
your platform.
Arduino Code:
The following code is used to work the camera using Arduino and get the
picture on your pc using processing tool. As an alternative, you can save
the data on SD card using Arduino card reader shield.
Processing is an open source language/ development tool for writing
programs in other computers. Useful when you want those other computers
to "talk" with an Arduino, for instance to display or save some data
collected by the Arduino.
For examples about using processing with Arduino , click here (http://
www.arduino.cc/playground/Interfacing/Processing)
LED_PIN 13
PAGE_SIZE 64
USB_BAUD 115200
CAMERA_BAUD 14400
void setup()
{
Serial.begin( USB_BAUD );
mySerial.begin(CAMERA_BAUD);
void loop()
{
if( Serial.available() ){
while(Serial.read() != -1);
digitalWrite( LED_PIN, HIGH );
if( !camera.sync() )
{
void setup()
{
println( Serial.list() );
myPort = new Serial( this, Serial.list()[0], 38400 );
}
void draw()
{
byte[] buffer = new byte[64];
if( readData )
{
while( myPort.available() > 0 )
{
int readBytes = myPort.readBytes( buffer );
print( "Read " );
print( readBytes );
println( " bytes ..." );
for( int i = 0; i < readBytes; i++ )
{
photo = append( photo, buffer[i] );
}
}
}
else
{
while( myPort.available() > 0 )
{
print( "COM Data: " );
println( myPort.readString() );
}
}
}
void keyPressed()
{
if( photo.length > 0 ) {
readData = false;
print( "Writing to disk " );
print( photo.length );
println( " bytes ..." );
saveBytes( filename, photo );
println( "DONE!" );
}
else {
readData = true;
myPort.clear();
println( "Waiting for data ..." );
}
}
Press the number corresponding to Arduino serial port on your PC. After a
while, it will stop and you can press ANY key again, it will show you:
and you can see photo below and image file in your Processing project
folder