programmatically disconnect a pin

Hello,

I need to “disconnect” a pin by software. Is there anything that could work with pinMode and digitalWrite.

This is because I have an Arduino ISP connecting to pins 10-13 and disturbing them in their function when I do not flash.
So I don’t want to disconnect the jack because it is also for power supply.

I have already modded the ArduinoISP sketch so I have a button and when I press it, then it should change to run sketch mode (instead of flash mode) , the button detection already works. Now I just need to disable these pins 10-13.

I have already shown that physically disconnecting them makes what I expect, so any suggestions how to do this in software gladly appreciated ;=)

KARLok

ISP.PNG

try setting pin mode to input with no pullup.

I'm kinda new to this, but from my view, if you put in a loop so it digitalWrite s pin 10/13 to 0 should work, or putting a 4k7 resistor somewhere

@doughboy Thanks!

    // seems to work - should help to avoid interference with Debug (Serial), when not Flash 
    pinMode(13, INPUT);
    pinMode(12, INPUT);
    pinMode(11, INPUT);    
    /*
dont do anything then (no pullup or other writing)
    digitalWrite(13, LOW);   
    digitalWrite(12, HIGH);    
    digitalWrite(11, HIGH);        
    */

@CaioTorre that would draw them to LOW i.e. culd also cause short circuit. btw looping thorough setting digitalwrite with same value is useless 'cause since it's one set keeps that val

I think this is very interessting also for other members of forum - didnt know for ages what to do, just asked and seems to work (It s yet to be prooven to work well)

Hey ya thanks for the tip. I am creating a DVM that reads negative voltages and so far using the change to INPUT tip for Hi-Z and the DigitalWrite output low to sink current is working.

The prototype is locking up sometime when going from INPUT to OUTPUT so I still have some more coding to do but when I'm done I'll post the final code somewhere.

From chapter 17 in the 328p datasheet:

“The External Interrupts are triggered by the INT pins or any of the PCINT pins. Observe that, if enabled,
the interrupts will trigger even if the INT or PCINT pins are configured as outputs.”

As long as the interrupts are enabled, a change will cause it to trigger. Changing from INPUT to OUTPUT will NOT disable the interrupt. To disable a PCINT you must do so on a pin-by-pin basis or the entire port.

I usually define two macros,

#define pcintX_on PORTn |= 1 << pcintX
#define pcintX_off PORTn &= ~(1 << pcintX)

which you can call whenever.