Is there any way to change digital pin 0,1 into digital INPUT

Hi,I am a student from Taiwan
I want to make digital pin 0 or 1 can read digital signal.
For example,look at test 1,it’s not working when I use it on auduino,the led(14 pin)didn’t light up when I
make pin 0 become ‘‘HIGH’’.
I think I didin’t make mistakes on hardware circuit,led(14 pin) should light up when I pin 0 is ‘‘HIGH’’.
If there is no mistakes in my hardware circuit,then it’s my program’s problem or pin 0 or 1 just can’t read or send digital signal.
My English is not very good.I type these sentences myself,so I’m not sure if I write it correctly.
If you can answer my question,please help me.I will be very appreciate.
Thank you.

test_1.ino (217 Bytes)

Which Arduino board are you using? Do you have a LED, with current limit resistor, connected to pin 14? How is the LED wired? Show a schematic.

You will get better and faster help if you follow the forum guidelines in the how to use this forum-please read sticky.

test2 is the schematic.

test2 is the program

Here it is for the benefit of others

#define A5 14

void setup()
{
  pinMode(0, INPUT);
  pinMode(14, OUTPUT);
}

void loop()
{
  if (digitalRead(0) == HIGH)
  {
    digitalWrite(14, HIGH);
  }
  else
  {
    digitalWrite(14, LOW);
  }
}

Now, can you please post a schematic of your circuit and describe the problems that you have.

To answer your question, yes, you can use digital pins 0 and 1 as digital inputs (if you know what you are doing), but why do you want or need to ? Have you run out of digital pins in your project and if so do you have spare analogue pins ?

Why have you #defined A5 as 14 ?

About teat1,I rewrite it again.It become test2. Please check it again,I know where I was wrong.Here is
the schematic.I have a problem that is I don’t have enough pins to use,and my problem is,I need pin0
to read digital signal.Here is the program.
I use arduino uno.Thank you.
void setup(){
pinMode(0,INPUT);
pinMode(19,OUTPUT);
}

void loop() {
if(digitalRead(0) == HIGH){
digitalWrite(19,HIGH);
}
else{
digitalWrite(19,LOW);
}
}
I have to make pin0 to read digital signal,so that led(pin19)can be light up.

I have a problem that is I don't have enough pins to use

There is no such problem in the code or the Fritzing diagram that you posted.

Have you used all of the analogue pins ?

Pin 0 is pulled up to 5v through a ~2.2k resistor because it's connected to the TX pin of the serial adapter through that, and an idle serial line is driven HIGH.

If you adhere to best practices for buttons, and wire the button so that pressing it connects the pin to ground, rather than 5v (and reverse the test in the code), it would work fine (of course, sending anything to it via serial would produce a bunch of false signals on the button, but you probably don't care; a 1k pullup resistor to 5v would be enough to overpower the effective 2.2k pullup if you do care (but such a resistor would have to be removed before trying to upload code, obviously).

UKHeliBob:
There is no such problem in the code or the Fritzing diagram that you posted.

Have you used all of the analogue pins ?

I think he's posting a minimal example, like we always ask people to... he clearly knows you can use analog pins as I/O, since he's doing so in the example.

Your wiring diagram shows no pull-down resistor on Pin 0 so when the button is open the input pin is left floating and may read 0 or 1.

Try this sketch and move the wire on the button from +5V to Gnd:

const byte ButtonPin = 0;
const byte LEDPin = A5;


void setup()
{
  pinMode(ButtonPin, INPUT_PULLUP);
  pinMode(LEDPin, OUTPUT);
}


void loop()
{
  // Turn on the LED whenever ButtonPin is grounded
  digitalWrite(LEDPin, !digitalRead(ButtonPin));  // Write the opposite of the input
}