problem getting touchshield to operate arduino pin

i am gorking on a project were i am using a simple menu on a touchshield slide to operate the ports of an arduino board. so far i found an example online, but the compiler gives me the error “error compiling file” . can some one help me?

here is the code i am using for the arduino:

//Arduino Mega and Duemilanove or Diecimilia

#include <SoftwareSerial.h>
#define rxPin 3
#define txPin 2

char myByte;
int ledPin = 13;//led on pin 13
int ten = 10;//pin 10
int eleven = 11;//pin 11
int ledPinfifty = 50;//pin 50 Mega only

SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);

void setup()
{
pinMode(rxPin, INPUT);//set recieve as an input
pinMode(txPin, OUTPUT);//set transmit as an output
pinMode(ledPin, OUTPUT);//set pin 13 led driver as an output
pinMode(ledPinfifty, OUTPUT);//set pin 50 as an output
pinMode(ten, OUTPUT);//
pinMode(eleven, OUTPUT);
digitalWrite(ten, LOW);//using pin ten to act as a ground (not reccomended)
mySerial.begin(9600);
}

void loop()
{

myByte = mySerial.read();
if(myByte == ‘A’) //if the letter “A” comes from the touchshield
{
digitalWrite(ledPin, HIGH); //Turn on the LEDs
digitalWrite(ledPinfifty, HIGH);
digitalWrite(eleven, HIGH);
}
if(myByte == ‘B’) //if the letter “B” comes from the touchshield
{
digitalWrite(ledPin, LOW);//Turn off the LEDs
digitalWrite(ledPinfifty, LOW);
digitalWrite(eleven, LOW);
}

delay(5);
}

I don't see a problem. What version of the IDE are you using.

I copied it into 0018 and it compiled fine.

i am using antipasto arduino 8.13. do you have the link for arduino 0018 version? looks like that is the problem.

thank you

Here you go.

thanks

hugo

There are major differences between the Liquidware antipasto version and version 0018. Both can be made to work well. I do a most of the development work on the touchSlide drivers and I have 3 different versions of the Arduino on my machine. For the Mega/Duemilanove version 0018 will be easier for you.

I have some documentation on the slide at

http://coewww.rutgers.edu/~msproul/arduino/

In your code, you dont need to set the pin modes for rxPin and txPin, mySerial.begin will take care of that.

Mark

will i have any problem if i program the touchshield and the mega with 2 different versions??

i got it working. thank you.Do you have any subjection to make it more reliable? When I touch the screen, it does the function I want on the screen, but I have to repeat it few times to get the output I want on the arduino ports.

Some suggestions, yes.

Post your code. If it's a code problem, we'll see it, and tell you about it. If it's not, we'll tell you that, too. Then, you can look at hardware issues.

I have several of the TouchSLide units and have not had any problem with any of them. The only difficulty is on the Arduino that is controlling it. Most people do not use it in that fashion but write the code on the slide itself. To control it from the Duemilanove you have to use softserial which is not very reliable at high speeds

I am working on a library that will communicate via one of the megas extra serial ports and take graphic commands.

Mark

here is the code i have on the slide. i figure i have something wrong with it because i did not change anything on the arduino code and with the example it works 100% of the time while it works less that 50% of the time with my code.

can you look at it and let me know what i am doing wrong?

thanks

/* this program is intended to create a control that operates the room lights,
the door, and a security camera. The final goal is to use bluetooth to do it wireless */

#include <SoftwareSerial.h>

void button (int left, int right , int top, int bottom, int colorA, int colorB, int colorC);// screen buttom function
void mainscreen(); // main screen menu function
int lights(int status, int intensity); //lights menu function

int lightshome=0; // lights status global variable

void setup(){

Serial.begin(9600); // begin serial

}

void loop(){

mainscreen: //mainscreen label

mainscreen();
mouseX=0;// start mouseX at 0 so the screen will wait for a screen touch on the while loop

while (mouseX == 0)//
{
gettouch();

if((mouseX < 77) && (mouseX > 2) && (mouseY < 208) && (mouseY > 131))
{
//lights:
lightshome = lights(1, 70); // initialice lights with staus (on ot off), and the intensity in case it is on
if (lightshome == 1)
goto mainscreen;
}
else
mouseX=0;
}

}

void button (int left, int right, int top, int bottom, int colorA, int colorB, int colorC)// provide left, right, top, and bottom coordinate then color specefications for the bottom
{
/* Draw the outline */

fill(colorA, colorB, colorC);
stroke(50);
rect(left, top, right-left, bottom-top);

/* draw button perimeter on white*/

stroke(255, 255, 255); //button white lines

line(left+3, top, right-3, top); //top line

line(left+3, bottom, right-3, bottom); //bottom line

line(left, top+3, left, bottom-3); //left line

line(right, top+3, right, bottom-3); //right line

/* Draw the radius corners */

stroke(255,255,255);
point(left + 2, top + 1);
point(left + 1, top + 2);

point(right - 2, top + 1);
point(right - 1, top + 2);

point(left + 2, bottom - 1);
point(left + 1, bottom - 2);

point(right - 2, bottom - 1);
point(right - 1, bottom - 2);

stroke(0, 0, 0);

point(left + 1, top + 1);
point(right - 1, top + 1);
point(left + 1, bottom - 1);
point(right - 1, bottom - 1);

stroke(255,255,255);
}

void mainscreen(void)
{
background(50,50,50); // fill the screen with gray

stroke(0, 0, 255);

text(“BLUETOOTH ROOM PROJECT”, 10,38,6); //print bluetooth on pixel 10,38 LETTER SIZE 6
text(“By Hugo Loaiza”, 10, 48);
text(“Owen Wei”, 28, 58);

button(2, 77, 131, 208, 0, 250, 0); //Lights button
stroke(0);
text(“LIGHTS”, 21, 168);
button(82, 157, 131, 208, 0, 250, 0); //Door button
stroke(0);
text(“DOOR”, 107, 168);
button(162, 237, 131, 208, 0, 250, 0); //Camera button
stroke(0);
text(“CAMERA”, 183, 168);
button(242, 317, 131, 208, 0, 250, 0); //Blank button
stroke(0);
text(“NEW”, 272, 168);
button(162, 237, 51, 126, 0, 250, 0); //Link button
stroke(0);
text(“LINK”, 190, 88);
button(242, 317, 51, 126, 0, 250, 0); //Status button
stroke(0);
text(“STATUS”, 262, 88);
}

int lights(int status, int intensity)
{
change: //status change label
background(50);

stroke(255);
text(“LIGHTS”, 10,38,10); // page title

/* Home bottom that takes back to main screen */
button(242, 318, 2, 78, 50, 50, 250);
text(“HOME”, 270, 38);

/* menu when lights are off */
if(status == 0) //if lights are off do the following
{

button(50, 150, 162, 238, 255, 0, 0);
stroke(255);
text(“OFF”, 93, 197);
button(170, 270, 162, 238, 100, 100, 100);
stroke(255);
text(“ON”, 218, 197);

}
else

/* menu when lights are on */
if(status == 1) //if lights are on, do the following
{

button(50, 150, 162, 238, 100, 100, 100);
stroke(255);
text(“OFF”, 93, 197);
button(170, 270, 162, 238, 0, 250, 0);
stroke(255);
text(“ON”, 218, 197);

button(20, 140, 64, 90, 0, 250, 0);
text(“INTENSITY”, 30, 77, 10);
button(222, 260, 95, 150, 0, 250, 0);
text("%", 253, 120);

change2: // intensity change label
button(20, 220, 95, 150, 50, 50, 50);
button(20, (20+(2*intensity)), 95, 150, 0, 250, 0);
text((short)intensity, 223, 120);

}
mouseX=0;
while(mouseX == 0) //loop to wait for menu option
{
gettouch();

/* if lights are off, then turn on and change intensity to 100% */
if((status == 0) && (mouseX > 170) && (mouseX < 270) && (mouseY > 162) && ( mouseY < 238))
{

Serial.print(‘A’); // write an “A” to the serial pins of the arduino to turn on the lights
delay(10);

status = 1;
intensity = 100;
goto change; // go to lights main manu
}

/* if lights are on, then turn off */
if((status == 1) && (mouseX > 50) && (mouseX < 150) && (mouseY > 162) && (mouseY < 238))
{

Serial.print(‘B’); // write a “B” to the serial pins of the arduino to turn off the lights
delay(10);

status = 0;
goto change; // go to lights main menu
}

/* if lights are on, then change the intensity of the lights */
if((status == 1) && (mouseX > 20) && (mouseX < 220) && (mouseY > 95) && (mouseY < 150))
{
intensity = ((mouseX - 20)/2);
goto change2; //go to intensity change lable to display de nuw intensity
}

/* exit from light menu and go to main screen */
if((mouseX > 242) && (mouseX < 318) && (mouseY > 2) && (mouseY < 78))
{
return 1;
}
else
mouseX = 0; // if get touch not valid, get mouseX = 0, so it can continue with the loop.
}
}