Rx pin == extra digital input

I am trying to use the Rx pin on a Nano 3.0 to read a microswitch.

Serial printing the digitalRead(0) value shows the Rx pin can read the microswitch perfectly.

However, when I try to pass the Rx pin state on using standard Firmata I get nothing, and some of the other digital inputs start behaving strangely.

Certain sections of the Firmata code treat the Tx and Rx pins differently, but I have not been able to determine if one of these sections is preventing the Rx pin state from being reported.

If anyone has any advice about how I might solve this problem I would love to hear it!

However, when I try to pass the Rx pin state on using standard Firmata

Am I reading this correctly? You're trying to read the state of the serial Rx pin using Firmata?

Are you trying to use the Rx pin both for reading a switch and for serial communication ?

That won't work!

Are you doing thid because you are running out of digital pins ?

If so do you know that you can use the analog pins as digital pins (if you have any free analog pins of course)

@ AWOL and MikMo, thanks for your replies :-)

@ AWOL: Yes, I am trying (and failing) to read the state of the serial Rx pin using Firmata.

@ MikMo: Yep, I am using the Rx pin out of desperation! (I've got sensors on all the other analog and digital pins).

[u]BUT[/u] the Rx pin is not being used for serial comm during sensor reading: When the Nano is reading the sensors I am passing this info onto a computer via an xbee radio. The only connection between the Nano and the xbee is Tx (Nano) -> DIN (data-in on xbee), and the data transfer works well.

For .pde uploading I am using usb. I find that if anything is connected to the Rx pin on the Nano (and brings the Rx pin to a high state) this interferes with uploading. So I have to disconnect the microswitch from the Rx pin before uploading, which is another problem I would like to try and find a work-around for.

I would be very grateful for any suggestions you might have!

For .pde uploading I am using usb. I find that if anything is connected to the Rx pin on the Nano (and brings the Rx pin to a high state) this interferes with uploading. So I have to disconnect the microswitch from the Rx pin before uploading, which is another problem I would like to try and find a work-around for.

This could be tough to work around, since the USB connection receives and transmits through the serial rx and tx pins (Arduino pins 0 & 1).

-Mike

aardvark,

Have you thought about upgrading to a Mega? Lots of pins on that baby.

Regards,

-Mike

Yup... you can't have anything connected to 0 or 1 while uploading.. or doing anything with a computer basically.

Tell us a little bit about your sensors and buttons.. there may be a way around.. maybe multiplex some inputs for buttons, or outputs for whatever you're using? Can also get some analog-input multiplexers..

What's your setup like?:)

@ Mike: moving to a different board is a good idea, I did not realise the Mega was such a pin monster! But for my project it would be better to have a board that is physically smaller than the Mega. I am wondering if there is a suitable board somewhere between the Nano (great size) and Mega (great pin count)? For example I noticed the Sanguino board:

http://sanguino.cc/

Maybe there is another suitable board I have not thought of?

Maybe there is another suitable board I have not thought of?

Yea, the Seeeduino Mega, same size as the standard Arduino but with even more pins then the Arduino Mega, and cheaper too!

http://www.seeedstudio.com/depot/seeeduino-mega-fully-assembled-p-438.html?cPath=27

Lefty

Agreeed, Seeeduino mega for the win! (haha.. I still haven't needed to solder the headers on.. saving it for an uber project)

Here's... some crappy pictures of the comparison of the Seeeduino Mega and the Duemilanove.. well I should say one picture.. the other pictures is the Case that they sell, love it because their mega fits in it perfectly.. with some other components, perfection! lol :)

http://picasaweb.google.com/jmcglo13/SeeeduinoMegaVsDuemilanove?feat=directlink

@ CaptainObvious and Retrolefty: whoa, that Seeduino is an absolute beast! I guess the ATmega1280 is much more power hungry than the 328? At the moment I can power the Nano with 2xAAA using the Bohdilabs 5v step-up pcb, but I guess this probably wouldn't cut it with the Seeduino?

@ CaptainObvious: Your multiplexing suggestion is an excellent one.

My project will have microswitches on every digital pin and potentiometers on all the analog inputs.

I guess multiplexing digital inputs would be easier? I will google this idea now.

Do you have any suggestions about what I should look for?

Maybe there is another suitable board I have not thought of?

I like the Teensy++...

http://www.pjrc.com/teensy/index.html

From the computer's perspective it looks and acts like a serial device but no I/O pins are used for communications.

Damn.. I wasn't aware of the Teensy.. that's sexy! I think I found my next board. :)

But anyways, here's an example of Multiplexing inputs. Keep in mind, this will give you only HIGH or LOW, you won't have any variable amounts, like analog inputs offer. http://www.arduino.cc/en/Tutorial/ShiftIn

There are chips that will offer you analog values but I don't have any experience with those, so I'll let someone else work their magic.

But btw, for an awesome reference site for everything Arduino: http://www.freeduino.org/ Use Control+F (find) to search on the page for whatever you're looking for.

@CaptainObvious: thanks for the multiplexing tip, I was looking for tutorials but did not come across that example myself. Looks like I have some homework to do...... :-)

@Coding Badly: great suggestion! I had never heard of the Teensy, and would never have come across it myself. The number of pins on the Teensy++ is amazing!

Have you tried running arduino .pdes on the Teensy? I can imagine I might have a few headaches trying to run firmata on it without some changes.

I see Tx and Rx pins on the board so I am assuming I can interface with an xbee fine.

I am a bit confused by the info on the site regarding ADC. In places it mentions that the Teensy++ has 10bit ADC, but the (original?) Teensy is described as having analog input pins. Does the Teensy have analog input pins but no ADC?

Thanks again!

In places it mentions that the Teensy++ has 10bit ADC, but the (original?) Teensy is described as having analog input pins. Does the Teensy have analog input pins but no ADC?

Analog inputs pins are the same as ADC (analog to digital conversion). I think it's just a semantics mix-up thing. Both the Teensy and Teensy++ have 10 bit ADC analog input pins, just the ++ has more of them.

Lefty

Analog inputs pins are the same as ADC

My thinking exactly! Thats why I have been confused by some of the descriptions. For example here:

http://www.elder-n00b.org/2009/04/teensy-arduino-for-small-quanities-of.html

the blogger mentions:

And while the Teensy's older brother Teensy++ also has analog inputs, the original Teensy lacks the Arduino's analog input options.

But maybe he is referring to an older version of the board.

The Teensy site says the Teensy has 25 I/O and 12 Analog pins, so I am assuming there are 13 digital pins to play with?

The Teensy site says the Teensy has 25 I/O and 12 Analog pins, so I am assuming there are 13 digital pins to play with?

Well normally analog input pins can also be used as digital input or output pins, so you should have up to 25 digital pins and up to 12 analog input pins, or any combination between those limits.

Lefty

The number of pins on the Teensy++ is amazing!

It is. And the price (in my opinion) is quite reasonable.

With pins, they work well on a breadboard. http://www.pjrc.com/store/teensy_pins.html http://www.pjrc.com/store/teensypp_pins.html

Without pins, it's very easy to solder parts and wires right onto the board. http://www.pjrc.com/store/teensy.html http://www.pjrc.com/store/teensypp.html

Have you tried running arduino .pdes on the Teensy?

I have and it's gone very well. I am very pleased with the product. I followed the instructions below and was running "blink" within 30 minutes (downloading and installing took most of that time)... http://www.pjrc.com/teensy/teensyduino.html

However, I've tried just one library; the Tone library. It does not compile. I suspect it's a simple problem.

On an unrelated issue, I emailed for support. It took a few days for the reply but Paul Stoffregen provided a very detailed and very helpful response. (Got to love it when the person who designed the thing replies in person!)

I can imagine I might have a few headaches trying to run firmata on it without some changes.

If you build a simple test with easy instructions I'm willing to run a test for you.

I see Tx and Rx pins on the board so I am assuming I can interface with an xbee fine.

I suspect that will work well. One of the advantages to the Teensy is Tx and Rx are not used to communicate with the host computer.

I am a bit confused by the info on the site regarding ADC. In places it mentions that the Teensy++ has 10bit ADC, but the (original?) Teensy is described as having [no] analog input pins. Does the Teensy have analog input pins but no ADC?

The "original" Teensy had no analog inputs. The Teensy currently for sale does have analog inputs. The Teensy++ has always had analog inputs.

But maybe he is referring to an older version of the board.

He is. I have an "old" one and it does not have analog inputs. The "new" one does.