Switching HIGH,LOW, INPUT

Hi everyone,

I asked a question few days ago but I wasn't able to clearly explain what I wanted to do.
So I just wanted to ask if this line of coding would work.

int pin0 = 0; int pin1 = 1; int pin2 = 2; int pin3 = 3;

void setup() {

pinMode(pin0, OUTPUT);
pinMode(pin1, OUTPUT);
pinMode(pin2, INPUT);
pinMode(pin3, INPUT);

}

void loop() {

digitalWrite(pin0, HIGH);
digitalWrite(pin1, LOW);
delay(1000);

pinMode(pin0, INPUT);
pinMode(pin2, OUTPUT);
digitalWrite(pin1, HIGH);
digitalWrite(pin2, LOW);
delay(1000);

pinMode(pin1, INPUT);
pinMode(pin3, OUTPUT);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, LOW);
delay(1000);

pinMode(pin2, INPUT);
pinMode(pin0, OUTPUT);
digitalWrite(pin3, HIGH);
digitalWrite(pin0, LOW);
delay(1000);

pinMode(pin3, INPUT);
pinMode(pin1, OUTPUT);

}

Thank you,

Gun

Depends what do you want it to do? If you want it to fuckup Serial it certainly will. Use code tags whan posting code.

Mark

If you mean can you change the direction of a pin, yes. You can call pinMode wherever you want in your code. All it does is set the direction register to configure the pin as input or output. What you are showing is common in a method called charlieplexing. It is also common in capacitance measurements to send a pulse on a pin and then immediately reconfigure that pin to an input to read how long the line stays high.

I believe this is your other Thread.

I can't see any reason for splitting the discussion.

...R