Is there a method of defining pins to be low immediately at start up?
Something simple like this, it appears pins are not going low until the Electron connects to the cloud?
void setup()
{
pinMode (A5, OUTPUT);
pinMode (A4, OUTPUT);
pinMode (A3, OUTPUT);
pinMode (A2, OUTPUT);
digitalWrite(A5, 0);
digitalWrite(A4, 0);
digitalWrite(A3, 0);
digitalWrite(A2, 0);
}
@Michael297, if your Electron is not running with SYSTEM_THREAD(ENABLE)
then the setup() code would not run until it connects to the Cloud. Most pins (except for the JTAG pin) will come up in tri-state or INPUT mode. One way to set the pins as quickly as possible after boot-up is to use the STARTUP() macro. Create a small function with your pin settings and place it before the STARTUP() command like this:
void setPinsLOW() {
pinMode (A5, OUTPUT);
pinMode (A4, OUTPUT);
pinMode (A3, OUTPUT);
pinMode (A2, OUTPUT);
digitalWrite(A5, 0);
digitalWrite(A4, 0);
digitalWrite(A3, 0);
digitalWrite(A2, 0);
}
STARTUP( setPinsLOW() );
void setup() {
}
void loop() {
}
1 Like