The application works as expected if I power on the device and then hook up the cameras. If I power on the device with the cameras plugged in, the device appears to shut down. I think this is true because some of the inputs I use are associated with the onboard LEDs, and when I power it on in this manner, the LEDs go down and I can't talk to the cameras anymore. I haven't experienced these kinds of issues on proper Arduino boards, so I am hoping that it's an issue with my code setup.
I've paired down my code to just one IO pin set up, and the application behaves the same way. Here is that code:
#define TOTAL_CAMERAS 1
#define CAMERA_0 0 //D3
int cameras[TOTAL_CAMERAS] = {
CAMERA_0
};
char val; //the incoming serial byte
void setup() {
Serial.begin(115200);
pinMode(CAMERA_0, FUNCTION_0);
pinMode(CAMERA_0, OUTPUT);
delay(10);
}
void loop() {
while (Serial.available()) {
val = Serial.read();
int camera = val - '0';
if (camera >= 0 && camera < TOTAL_CAMERAS) {
fireCamera(cameras[camera]);
Serial.println("fire single camera");
}
}
delay(10);
}
void fireCamera(int camera) {
digitalWrite(camera, HIGH);
delay(SHUTTER_DELAY);
digitalWrite(camera, LOW);
}
Can you see anything obviously wrong in that code that would cause my app to behave this way> I've gone over my circuit fairly thoroughly, and I think it's OK, but if it's not I can get more in depth with information about that. Thanks very much!