Tuesday, May 12, 2009

Arduino Mega Meets the Touchshield

It all started a few weeks ago, when my friend Lee insisted on making the TouchShield tell the Arduino to turn on an LED...

The Arduino code is compatible on the Duemilanove and the Mega
The TouchShield code is compatible on the Stealth and the Slide


If the inside of the circle is pressed, a signal is sent to the Arduino, telling it to turn on the LED

If the outside of the circle is pressed, a signal is sent to the Arduino, telling it to turn off the LED


Inside the circle is on...


The code is over here
And I made a quick video demo...

6 comments:

Justin said...

so that's what the slide looks like with the arduino mega! anyway, that's a pretty neat program :)

ChuckT said...

Is the Serial on the Stealth or Slide Hardware or Software? If I'm not using the USB, can you do Hardware Serial on the Stealth or Slide?

Mike Gionfriddo said...

TouchShield Stealth is Software Serial.

TouchShield Slide is Hardware Serial.

Arduino is SoftwareSerial (Adafruit version)

dancy_1 said...

Well there ya go, I have been working on this for about seven days before Severino made this post. Let me share some of my findings with ya'll.

I had been reading up on SoftSerial and most posts advised against its use stating several problems with the original code, AFSoftSerial being the recommended replacement. Going to Lady Ada's site you find a redirect to Mikail's NewSoftSerial. In correspondence with Mikail, he indicated the new libraries had not been tested with the Mega.

All this investigation was prompted by the fact that I could not get any of the sample Shield<->Arduino communication programs to work. I dragged my silly-scope out and it confirmed that the Shield was doing as told and serial data was being sent on pin 3. That narrowed the problem down to the Mega. Tried many flavors and mod’s to the test application but could never get any of the pseudo serial applications to function on the Mega. Both AFSoftSerial and NewSoftSerial calls to mySerial.read() only returned 0xFF.
My analysis of Severino’s code and observation of the output shows that he has the key press “ lock” and then the Shield sends a stream of the letter A or B. Eventually, one gets through and the LED changes state. A rough estimate of an A or B getting through is about 150 to one (150 TX to one accurate RX). For my application that was nowhere near accurate enough. Since the Mega has four hard serial ports I decided to remove the TouchShield from the Mega and use jumpers to the appropriate pins. The results were amazing. I changed the latching push button to a momentary and now the LED action is very crisp. My recommendation would be to modify the TouchShield to incorporate a couple of horizontal pins opposite the power connector on the Mega that could be jumped to one of the Mega hard serial headers. That way it could still be used in the shield configuration for older Arduinos and the Mega as well.

Dan Clemens
Summerville, Or

ndudman said...

I'm so pleased to see this statement about the Mega and touchshield... after spending too much time trying to get something other than Softserial at 4800 to work i.e both NewSoftWerial and AFSoftSerial (of course not reading their docs until just now) and realising that the Mega wasn't supported and also had 4 of its own high speed hardware serials. So will follow the previous commenters advise and disconnect from normal place and fix with jumpers, just a shame I can't have the screen nicly secured ontop of the Mega.

Tai said...

I was able to solder in wires to the touchshield at pin 2 and 3. This allows it to lay flat upon the Mega. I have tested that 2 and 3 are working via newsoftserial, however, I am unable to receive data from any of the Mega's hardware serial ports. I have loaded code on the Mega that sends on Serial3 and using usart1 for the touchshield. Any suggestions?

Thanks,
TW