Pages: [1]   Go Down
Author Topic: Using digital pins 0 and 1  (Read 262 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am currently working on a fairly complicated project at the moment which uses all but one pin on my Arduino Uno so I'm having to use digital pins 0 and 1 as inputs but for some reason I cannot get digital pin 0 to work whereas pin 1 works fine. Digital pin 0 seems to read high all the time but I cannot check as serial obviously wont work with pins 1 and 2 in use.

The pins are being used to detect a signal from a hall effect sensor to find the position of 2 servo motors, the inputs have 10k pull-down resistors on them.

Here is the code that reads the pins, it is run in void setup()

Code:
void calibrateMotors(){
  boolean calibrated = 0;
   motor1pos = 4096; //pretend that the motors are 4096 steps ahead of 0
   motor2pos = 4096;
   
while(calibrated == 0){
 if(digitalRead(0) == HIGH){ //if input is high...
  motor1pos = 0; //motor is zeroed
 }
 if(digitalRead(1) == HIGH){
  motor2pos = 0;
 }
if(motor1pos == 0 && motor2pos == 0){ //if both motors are calibrated...
 calibrated = 1; //end the while loop
}
else{
 stepperMove(0,0,1);  //otherwise move the motor(s) back a step if they arent zeroed yet
}
 }
}

The pins are declared as inputs in void setup() before the code is run. Serial is not used anywhere else in the program.

So am I missing something really obvious here? I could not find any special requirments for using digital pins 0 and 1.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6632
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Pin 0 essentially has a pretty strong external pullup (1k) because of the connection to the USB chip TXdata signal (which is "high" in idle state.)
Since there is a 1K resistor, you should be ok to connect pin 0 to "stong" logic signals, but it's not ever going to behave like a true high-impedence input (and your 10k pulldown resistor won't be enough...)
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 473
Posts: 18695
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Swap things around so pins 0 and 1 are used as outputs only. Use another set of pins for inputs, for the reasons westfw gave.
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the quick replies. I guess I'll use them as outputs then.
Logged

Pages: [1]   Go Up
Jump to: