Confused About Behavior of IO Pins on Boot
Posted: Fri Feb 10, 2017 7:40 pm
I am really confused about behavior I'm observing with my application. I am trying to control 10 cameras through USB serial on a NodeMCU board. I am new to ESP8266 (this is my first project beyond simple examples), but accustomed to the Arduino platform, and I'm not an electrical engineer, so bear with me. We want to try to stick to the NodeMCU board because of all the advantages it has over Arduino.
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:
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!
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:
Code: Select all
#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!