spresense code
#include <Camera.h>
//#define BAUDRATE 1152000
void CamCB(CamImage img){
if(img.isAvailable() == false) return;
while (Serial2.available() <= 0);
//start by receving 's'
if(Serial2.read() != 'S') return;
delay(1);
digitalWrite(LED0, HIGH);
img.convertPixFormat(CAM_IMAGE_PIX_FMT_RGB565);
char *buf = img.getImgBuff();
for (int i = 0; i < img.getImgSize(); ++i, ++buf){
Serial2.write(*buf);
}
digitalWrite(LED0, LOW);
}
void setup() {
Serial2.begin(1152000);
while (!Serial2) {};
theCamera.begin();
theCamera.startStreaming(true, CamCB);
theCamera.setAutoWhiteBalanceMode(CAM_WHITE_BALANCE_DAYLIGHT);
}
void loop(){
/* do nothing */
}
Processing side
import processing.serial.*;
import java.io.*;
Serial myPort;
PImage img;
final static int WIDTH = 320;
final static int HEIGHT = 240;
boolean started = false;
int serialTimer = 0;
int total = 0;
int x = 0;
int y = 0;
void setup(){
size(320, 240);
background(0);
img = createImage(WIDTH, HEIGHT, RGB);
myPort = new Serial(this, "COM7", 115200);
myPort.clear();
println("setup Finished");
delay(2000);
}
void draw(){
if (started == false){
started = true;
println("Start");
myPort.write('S');
myPort.clear();
total = 0;
delay(10);
return;
}
// To get a stable connection adjust this inerval
final int interval = 1;
if(millis() - serialTimer > interval){
serialTimer = millis();
if(myPort.available() <=0) return;
while (myPort.available() >0) {
char lbyte = (char)myPort.read();
char ubyte = (char)myPort.read();
x = total % WIDTH;
y = total / WIDTH;
int value = (ubyte << 8) | (lbyte);
char r = (char)(((value & 0xf800) >> 11) << 3);
char g = (char)(((value & 0x07E0) >> 5) << 2);
char b = (char)((value & 0x001f) << 3);
color c = color(r, g, b);
img.set(x, y, c);
++total;
if (total >= WIDTH*HEIGHT){
println("end");
myPort.clear();
started = false;
total = 0;
image(img, 0, 0);
break;
}
}
}
}
I have tested the bluetooth with a button and turning on and off one of the built in leds and that seems to work. I have posted the code from both programs. Other than changing the serial port on the board this code was some that I have found online.