2.8" TFT Touch Shield Switch Example on Arduino Duemilanove

*** UPDATE*** Pictures enclosed as requested
Not anything to go write home about - the sketch just uses the touch sensor to toggle two buttons for on and off while displaying the state of the buttons - connecting a LED to the two remaining Digital Pins (Digital 0 and 1) isn’t in the sketch - YET! I just wanted to make a practical test sketch that tested the Touch Screen.

Original Post Below******************
Hello,

I created my own “TFT Touch Shield” example sketch for my Arduino Duemilanove and in need of connecting it via I2C bus to my Arduino Nano 3.0 (ATMEGA328). After plugging into my serial shield which is in turn plugged into my Duemilanove, I had only Digital 0 and 1 , and Analog 4 and 5 left available for use.

Is Connection to an I2C bus possable with my Duemilanove, and if so what would I have to configure to do so.

If it helps here is my TFT Touch Shield Example Sketch - the sketch was made with the Seeedstudio examples provided on your Wiki for the 2.8" Touch Shield. Please feel free to chop it up as it’s my first attempt at programming. I really need the feedback. (pls post ONLY constructive though)

Touch Shield Project.jpg

Touch Shield Project 001.jpg
Touch Shield Project 000.jpg
*********** CODE BELOW********************************************
//Pls see the remarks at the bottom for the original disclaimers.
//This TFT Touch Shield Sketch was created by Joe Parsons from examples provided.
//In order to run I had to get the Libraries for Arduino V1.0 from the Seeedstudio Wiki
//This example was made from pretty much all the examples provided by the Wiki page.
//I was going to use I2C to connect to another Arduino or connect to a LED.
#include <stdint.h>
#include <TouchScreen.h>
#include <TFT.h>

#define YP A2 // must be an analog pin, use “An” notation!
#define XM A1 // must be an analog pin, use “An” notation!
#define YM 14 // can be a digital pin, this is A0
#define XP 17 // can be a digital pin, this is A3

//Measured ADC values for (0,0) and (210-1,320-1)
//TS_MINX corresponds to ADC value when X = 0
//TS_MINY corresponds to ADC value when Y = 0
//TS_MAXX corresponds to ADC value when X = 240 -1
//TS_MAXY corresponds to ADC value when Y = 320 -1

#define TS_MINX 140
#define TS_MAXX 900
#define TS_MINY 120
#define TS_MAXY 940

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); //init TouchScreen port pins

void setup()
{

Serial.begin(9600); // initial connection to serial
Tft.init(); //init TFT library
pinMode(0,OUTPUT);

//Text Box with outline
Tft.fillRectangle(0, 4, 239,63,RED);
Tft.drawRectangle(1, 5, 237,62,BLUE);
//Text to Display
Tft.drawString(“LED OFF”,50,27,3,WHITE);

//Initial Buttons Backdrop Colors
Tft.fillCircle(60, 120, 40,550055); // Right Circle
Tft.fillRectangle(60, 80, 120, 80,550055); //Rectangle in Ctr
Tft.fillCircle(180, 120, 40,550055); //Left Circle
//white line seperator
Tft.drawVerticalLine(120,80,80,WHITE);
Tft.fillCircle(180, 120, 30,555555);//input right circle
Tft.fillCircle(60, 120, 30,555555);//input left circle
}
void loop()
{
// Gets the Touch Screen input and holds x y and z coordinates.
Point p = ts.getPoint();
// I think this sets the Maximum and Minimum Horz. and Vert. scale - unsure.
p.x = map(p.x, TS_MINX, TS_MAXX, 240, 0);
p.y = map(p.y, TS_MINY, TS_MAXY, 320, 0);

// Runs when the touch Screen is pressed. 
if (p.z > ts.pressureThreshhold) 
{ 
   if(p.y  >=90 && p.y <120) //sets the Horizonal Scale for Touch Input
    {
       if (p.x >=50 && p.x <80) //Sets the Vertical Scale for Touch Input
       { 
       // Display for the ON Selection
       Tft.fillCircle(60, 120, 30,GREEN);//input left circle
       Tft.fillCircle(180, 120, 30,555555);//input right circle
       Tft.fillRectangle(0, 4, 239,63,GREEN);//Title Banner Background
       Tft.drawRectangle(1, 5, 237,62,BLUE);
       //Text to Display if ON
       Tft.drawString("LED ON",50,27,3,WHITE);
       //PLACE MARKER FOR LED CODE TO BE TURNED ON
       }
       else 
       {
       // Display for the OFF Selection
       Tft.fillCircle(60, 120, 30,555555);//input left circle
       Tft.fillCircle(180, 120, 30,RED);//input right circle
       Tft.fillRectangle(0, 4, 239,63,RED);//Title Banner Background
       Tft.drawRectangle(1, 5, 237,62,BLUE);//Title Border Color
       //Text to Display if OFF
       Tft.drawString("LED OFF",50,27,3,WHITE);
       //PLACE MARKER FOR LED CODE TO BE TURNED ON
       }        
     } 
 }

delay(100);
}
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Dear customer,

Thanks for your sharing and if you success with your project that attach more information, photo it would be helpful.

Best regards,

Yuri