Go Down

Topic: Sparkfun Pro Mini: Shorting Tx and Rx (Read 994 times) previous topic - next topic

_Leo_

While the board is connected to power is it possible to short the Tx and Rx pins together for a second without damaging any components?

If so, would it possible to read the state when both pins are shorted?

Code: [Select]

void setup()
{

????

}

void loop()
{

Tx_Rx_Short = read status

if(Tx_Rx_Short == true) do something special;

}


Thanks.
Leo

Project "ALTDuino" - A homemade altimeter for model rockets.
http://www.altduino.de

kurt_t

Shorting those two pins together won't cause any harm unless one pin is driving HIGH and the other pin is driving LOW. Why are you checking if those two pins are shorted together? Are you using a pushbutton to do this? If so, you should look into using the pull-up resistors built into the Arduino.

Here's a tutorial about using a pushbutton and a pull-up resistor: http://www.arduino.cc/en/Tutorial/Pushbutton

A better way would be to use the internal pull-up resistors in the Arudino: http://arduino.cc/en/Tutorial/DigitalPins
Collaborate on open source hardware at Open Hardware Hub

_Leo_

Thanks Kurt.

I only have those 2 pins to go with and I don't have an option with pull-ups unless they are already on the Pro Mini as default. No pushbutton will/can be used. The short will be done with any kind of metal object.

The pins are in a dead state with the Pro Mini only being powered by a battery (Lipo) but only until it gets hooked up to a USB port.

So what would you suggest? How can I read the state using the code example I posted?

Leo

Project "ALTDuino" - A homemade altimeter for model rockets.
http://www.altduino.de

CrossRoads

byte Pin1 = 1;
void setup(){
pinMode (Pin1, INPUT);
digitalWrite (PIN1, HIGH); // turn on internal pullup
}
void loop(){
   if (digitalRead (Pin1) == LOW){
   // pin is shorted to Gnd
   }
}
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

kurt_t

The RX pin is D0 and the TX pin is D1. According to http://arduino.cc/it/Main/ArduinoBoardProMini, all of the digital pins have interal pullup resistors. You can set D0 as an INPUT, turn on the pullup resistor on D0, and drive LOW on D1. When you read the value on D0, LOW means there is a short, and HIGH means there is an open.

Code: [Select]

void setup()
{
  pinMode(0, INPUT);
  digitalWrite(0, HIGH);
  pinMode(1, OUTPUT);
  digitalWrite(1, LOW);
}

void loop()
{
  if(digitalRead(0) == LOW)
  {
    //do something special
  }
}
Collaborate on open source hardware at Open Hardware Hub

_Leo_

Thanks guys.

@Kurt: That's exactly the confirmation I was looking for. I was to chicken to experiment. I will let you know here if the result turned out as planned.
Leo

Project "ALTDuino" - A homemade altimeter for model rockets.
http://www.altduino.de

kurt_t

Collaborate on open source hardware at Open Hardware Hub

kf2qd

Could you not use an analog input to read a switch?

kurt_t


Could you not use an analog input to read a switch?


Yeah, I suggested that, but apparently he can't add a button to his design.
Collaborate on open source hardware at Open Hardware Hub

_Leo_

A switch is heavy and uses space.

The 2 pins on the mini on other hand are present. So if I can use them as a switch aswell, then I'm happy  :)
Leo

Project "ALTDuino" - A homemade altimeter for model rockets.
http://www.altduino.de

CrossRoads

Pro mini? You have the 2 inboard pins as well, A4 and A5 (D18, D19).
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

_Leo_

#11
Jul 24, 2012, 08:34 pm Last Edit: Sep 18, 2012, 08:50 pm by _Leo_ Reason: 1
Here is something I quickly put together.

http://www.altduino.de/

I think it should answer some questions.
Leo

Project "ALTDuino" - A homemade altimeter for model rockets.
http://www.altduino.de

_Leo_


The RX pin is D0 and the TX pin is D1. According to http://arduino.cc/it/Main/ArduinoBoardProMini, all of the digital pins have interal pullup resistors. You can set D0 as an INPUT, turn on the pullup resistor on D0, and drive LOW on D1. When you read the value on D0, LOW means there is a short, and HIGH means there is an open.

Code: [Select]

void setup()
{
  pinMode(0, INPUT);
  digitalWrite(0, HIGH);
  pinMode(1, OUTPUT);
  digitalWrite(1, LOW);
}

void loop()
{
  if(digitalRead(0) == LOW)
  {
    //do something special
  }
}



Well, that was a fight I didn't anticipate in but I finaly got the above code to work.

Turns out if you have Serial.begin(xxx); activ digitalRead(0) will always be HIGH.

That in turn caused quit a few new problems which thankfully I have managed to solve aswell.
Leo

Project "ALTDuino" - A homemade altimeter for model rockets.
http://www.altduino.de

Go Up