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.
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 ?
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.
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.