Pages: [1]   Go Down
Author Topic: Sparkfun Pro Mini: Shorting Tx and Rx  (Read 807 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Jr. Member
**
Karma: 3
Posts: 83
I'm a newbie
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
void setup()
{

????

}

void loop()
{

Tx_Rx_Short = read status

if(Tx_Rx_Short == true) do something special;

}

Thanks.
Logged

Leo

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


Atlanta, GA
Offline Offline
Newbie
*
Karma: 0
Posts: 20
I <3 open source hardware
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Collaborate on open source hardware at Open Hardware Hub

Germany
Offline Offline
Jr. Member
**
Karma: 3
Posts: 83
I'm a newbie
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Logged

Leo

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


Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 533
Posts: 26956
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
   }
}
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Atlanta, GA
Offline Offline
Newbie
*
Karma: 0
Posts: 20
I <3 open source hardware
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
void setup()
{
  pinMode(0, INPUT);
  digitalWrite(0, HIGH);
  pinMode(1, OUTPUT);
  digitalWrite(1, LOW);
}

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

Collaborate on open source hardware at Open Hardware Hub

Germany
Offline Offline
Jr. Member
**
Karma: 3
Posts: 83
I'm a newbie
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Leo

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


Atlanta, GA
Offline Offline
Newbie
*
Karma: 0
Posts: 20
I <3 open source hardware
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Glad to help smiley
Logged

Collaborate on open source hardware at Open Hardware Hub

South Texas
Offline Offline
Edison Member
*
Karma: 8
Posts: 1025
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Atlanta, GA
Offline Offline
Newbie
*
Karma: 0
Posts: 20
I <3 open source hardware
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Collaborate on open source hardware at Open Hardware Hub

Germany
Offline Offline
Jr. Member
**
Karma: 3
Posts: 83
I'm a newbie
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley
Logged

Leo

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


Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 533
Posts: 26956
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Pro mini? You have the 2 inboard pins as well, A4 and A5 (D18, D19).
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Germany
Offline Offline
Jr. Member
**
Karma: 3
Posts: 83
I'm a newbie
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is something I quickly put together.

http://www.altduino.de/

I think it should answer some questions.
« Last Edit: September 18, 2012, 01:50:37 pm by _Leo_ » Logged

Leo

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


Germany
Offline Offline
Jr. Member
**
Karma: 3
Posts: 83
I'm a newbie
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
Logged

Leo

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


Pages: [1]   Go Up
Jump to: