Just an FYI - I am pretty sure that these boards do not support INPUT_PULLDOWN.
Which I verified in the code, that it simply does the same as pinMode(pin, INPUT);
For awhile I thought my MINIMA board was having major issues, as I tried running a slightly modified version of a pin test that I use on Teensy boards (and others).
//#ifdef ESP_PLATFORM
#define digitalWriteFast digitalWrite
#define digitalReadFast digitalRead
//#endif
void setup() {
Serial.begin(115200);
while (!Serial && millis() < 4000 );
//Serial.println("Compile Time:: " __FILE__ " " __DATE__ " " __TIME__);
Serial.print("Num Digital Pins: ");
Serial.println(NUM_DIGITAL_PINS, DEC);
Serial.flush();
testForShorts();
}
uint32_t cnt = 0;
void loop() {
cnt++;
allPinTest( cnt );
}
uint32_t pinLast[NUM_DIGITAL_PINS];
void allPinTest( uint32_t cnt ) {
uint32_t ii, SET;
Serial.print("PULLDOWN Start Vals:\n ");
SET = 1;
Serial.print("PULLDOWN :: TEST to 3.3V\n ");
for ( ii = 0; ii < NUM_DIGITAL_PINS; ii++) {
pinMode( ii, INPUT_PULLDOWN );
delayMicroseconds( 5 );
pinLast[ii] = digitalReadFast( ii );
if (pinLast[ii]) {
Serial.print("\nd#=");
Serial.print( ii );
Serial.print( " val=" );
}
Serial.print( pinLast[ii] );
Serial.print(',');
}
Serial.println();
Serial.println();
while ( 1 ) {
uint32_t jj, dd = 0, cc = 0, ee=4;
cc = 0;
for ( ii = 0; ii < NUM_DIGITAL_PINS; ii++) {
jj = digitalReadFast( ii );
if ( jj != pinLast[ii] ) {
dd = 1;
cc++;
pinLast[ii] = jj;
Serial.print("d#=");
Serial.print( ii );
if ( pinLast[ii] ) Serial.print( "\t" );
Serial.print( " val=" );
Serial.print( pinLast[ii] );
Serial.print(',');
}
if ( cc > 1 && ee ) {
Serial.println(">>> MULTI CHANGE !!");
ee--;
}
if ( Serial.available() ) {
while ( Serial.available() ) Serial.read();
if ( 0 == SET ) {
SET = 1;
Serial.print("PULLUP :: TEST TO GND\n ");
}
else {
SET = 0;
Serial.print("PULLDOWN :: TEST to 3.3V\n ");
}
for ( ii = 0; ii < NUM_DIGITAL_PINS; ii++) {
if ( 0 == SET )
pinMode( ii, INPUT_PULLDOWN );
else
pinMode( ii, INPUT_PULLUP );
delayMicroseconds( 20 );
pinLast[ii] = digitalReadFast( ii );
if (SET != pinLast[ii]) {
Serial.print("d#=");
Serial.print( ii );
Serial.print( " val=" );
Serial.println( pinLast[ii] );
}
}
}
}
if ( dd ) {
dd = 0;
Serial.println();
delay( 50 );
}
}
}
void testForShorts() {
uint32_t ii;
Serial.print("Quick Test for Shorts to adjacent pin");
Serial.println("First pull pins down and see if the next one follows");
for ( ii = 0; ii < NUM_DIGITAL_PINS-1; ii++) {
pinMode( ii+1, INPUT_PULLDOWN );
pinMode( ii, OUTPUT);
digitalWrite(ii, HIGH);
delayMicroseconds( 5 );
if (digitalRead(ii+1)) {
Serial.print(ii,DEC);
Serial.print(":");
Serial.println(ii+1, DEC);
}
}
Serial.println("\n Now try Pull up and see if setting low follow");
for ( ii = 0; ii < NUM_DIGITAL_PINS-1; ii++) {
pinMode( ii+1, INPUT_PULLUP );
pinMode( ii, OUTPUT);
digitalWrite(ii, LOW);
delayMicroseconds( 5 );
if (!digitalRead(ii+1)) {
Serial.print(ii,DEC);
Serial.print(":");
Serial.println(ii+1, DEC);
}
}
Serial.println();
}
The code basically allows you to try to set all of the IO pins to either INPUT_PULLUP or INPUT_PULLDOWN. And then cycles scanning all of the pins to see if any pins have changed state.
So for example if you are in INPUT_PULLUP mode, and you have a jumper to GND, if you touch an IO pin it will print out which pin changed state. Which helps when sometimes what you think you have attached to a device is not... Like off by one issues...
It also helps pinpoint possible shorts, that is if I touch one pin and 3 change state, then maybe something is wrong...
Is working ok in this state, but tried with INPUT_PULLDOWN where you try to jumper from 3.3v or 5v to different pins, to see if any changes. In this case I was getting tons of random pins changing state. I was also getting several pins changing state when I simply changed if I was holding a wire to gnd or not... Which makes sense as all of the IO pins states are floating.
May still be an issue with my minima, as if I try the jumper in the PU state to pin 13, nothing shows up, and I then felt the temperature of the processor going up...
Again post is mostly just a heads up, on INPUT_PULLDOWN.

