PinMode setup question

Hello,

Can I set pinMode as Input or Output according to an EEPROM value?

Like that?

#include <EEPROM.h>

byte value=0;

void setup() {
  value = EEPROM.read(0);

  if (value==0)
    pinMode(3,INPUT_PULLUP);
  else
    pinMode(3,OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:

}

(Sketch compiles)

Thank you
Pete

Can I set pinMode as Input or Output according to an EEPROM value?

Yes

If you are feeling brave (or foolish) you can even do

    pinMode(3,EEPROM.read(0));

as long as the EEPROM contains the appropriate value INPUT = 0 OUTPUT = 1 INPUT_PULLUP = 2

But be aware that there are some changed afoot to do with the values that prevent this working

Perfect, thank you very much! I like your shortcut as well but because of the reason you said, I'll stick with the if statement and the commands instead of numbers.

I am not sure why you want to read the required pinMode() from EEPROM but if you need to you can change the pinMode() on the fly anywhere in the program