Hi hier der komplette sketch
Das Relais1 und Relais2 sollen immer im wechsel geschaltet werden
// ITDB02_Touch_Button
// This program is a quick demo of how create and use buttons.
//
// This program requires the ITDB02_Graph library (8bit mode)
// or ITDB02_Graph16 (16bit mode).
//
// It is assumed that the ITDB02 module is connected to a
// ITDB02 Shield, a ITDB02 Mega Shield or that you know how
// to change the pin numbers in the setup.
//
#include <UTFT.h>
#include <ITDB02_Touch.h>
// Declare which fonts we will be using
extern uint8_t BigFont[];// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int Relais6 = 13;
int Relais5 = 12;
int Relais4 = 11;
int Relais3 = 10;
int Relais2 = 9;
int Relais1 = 8;
int Relais7 = 7;
// Uncomment the next line for Arduino 2009/Uno
//UTFT myGLCD(ITDB32S,19,18,17,16); // Remember to change the model parameter to suit your display module!
//ITDB02_Touch myTouch(15,10,14,9,8);
// Uncomment the next line for Arduino Mega
UTFT myGLCD(ITDB32S,38,39,40,41); // Remember to change the model parameter to suit your display module!
ITDB02_Touch myTouch(6,5,4,3,2);
int x, y;
char stCurrent[20]="";
int stCurrentLen=0;
char stLast[20]="";
void setup()
{
// Initial setup
myGLCD.InitLCD(LANDSCAPE);
myGLCD.clrScr();
myTouch.InitTouch(LANDSCAPE);
myTouch.setPrecision(PREC_MEDIUM);
myGLCD.setFont(BigFont);
//myGLCD.setBackColor(0, 0, 255);
// initialize the digital pin as an output.
pinMode(Relais6, OUTPUT);
pinMode(Relais5, OUTPUT);
pinMode(Relais4, OUTPUT);
pinMode(Relais3, OUTPUT);
pinMode(Relais2, OUTPUT);
pinMode(Relais1, OUTPUT);
pinMode(Relais7, OUTPUT);
// Draw the upper row of buttons
for (x=0; x<6; x++);
{
myGLCD.setBackColor (0, 0, 0);
myGLCD.setColor(255, 255, 255);
myGLCD.fillRoundRect (190, 15, 240, 40);
myGLCD.drawRoundRect (190, 15, 240, 40);
myGLCD.print("BAD&KUECHE", 10, 20);
myGLCD.print("ON", 200, 20);
myGLCD.fillRoundRect (250, 15, 300, 40);
myGLCD.drawRoundRect (250, 15, 300, 40);
myGLCD.print("OFF", 250, 20);
myGLCD.print("WOHN", 10, 60);
myGLCD.fillRoundRect (190, 55, 240, 80);
myGLCD.drawRoundRect (190, 55, 240, 80);
myGLCD.print("ON", 200, 60);
myGLCD.fillRoundRect (250, 55, 300, 80);
myGLCD.drawRoundRect (250, 55, 300, 80);
myGLCD.print("OFF", 250, 60);
myGLCD.print("AUSSEN", 10, 100);
myGLCD.fillRoundRect (190, 95, 240, 120);
myGLCD.drawRoundRect (190, 95, 240, 120);
myGLCD.print("ON", 200, 100);
myGLCD.fillRoundRect (250, 95, 300, 120);
myGLCD.drawRoundRect (250, 95, 300, 120);
myGLCD.print("OFF", 250, 100);
myGLCD.print("RADIO", 10, 140);
myGLCD.fillRoundRect (190, 135, 240, 160);
myGLCD.drawRoundRect (190, 135, 240, 160);
myGLCD.print("ON", 200, 140);
myGLCD.fillRoundRect (250, 135, 300, 160);
myGLCD.drawRoundRect (250, 135, 300, 160);
myGLCD.print("OFF", 250, 140);
myGLCD.print("TERRASSE", 10, 180);
myGLCD.fillRoundRect (190, 175, 240, 200);
myGLCD.drawRoundRect (190, 175, 240, 200);
myGLCD.print("ON", 200, 180);
myGLCD.fillRoundRect (250, 175, 300, 200);
myGLCD.drawRoundRect (250, 175, 300, 200);
myGLCD.print("OFF", 250, 180);
myGLCD.print("UMSCHALTUNG", 10, 220);
myGLCD.fillRoundRect (190, 215, 240, 239);
myGLCD.drawRoundRect (190, 215, 240, 239);
myGLCD.print("G", 200, 220);
myGLCD.fillRoundRect (250, 215, 300, 239);
myGLCD.drawRoundRect (250, 215, 300, 239);
myGLCD.print(" A ", 250, 220);
}
}
void updateStr(int val)
{
if (stCurrentLen<20)
{
stCurrent[stCurrentLen]=val;
stCurrent[stCurrentLen+1]='\0';
stCurrentLen++;
myGLCD.setColor(0, 255, 0);
myGLCD.print(stCurrent, LEFT, 224);
}
{
}
}
// Draw a red frame while a button is touched
void waitForIt(int x1, int y1, int x2, int y2)
{
myGLCD.setColor(255, 0, 0);
myGLCD.drawRoundRect (x1, y1, x2, y2);
while (myTouch.dataAvailable())
myTouch.read();
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect (x1, y1, x2, y2);
}
void loop()
{
while (true)
{
if (myTouch.dataAvailable())
{
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
{
if ((y>=15) && (y<=40)) // Upper row
{
if ((x>=190) && (x<=240)) // Button: Bad & KÜCHE ON
{
digitalWrite(Relais5, LOW); // turn the LED on (HIGH is the voltage level)
waitForIt(190, 15, 240, 40);
}
if ((x>=250) && (x<=300)) // Button: Bad & KÜCHE OFF
digitalWrite(Relais5, HIGH); // turn the LED on (HIGH is the voltage level)
waitForIt(250, 15, 300, 40);
}
{
if ((y>=55) && (y<=80)) // Upper row
{
if ((x>=190) && (x<=240)) // Button: WOHN ON
{
digitalWrite(Relais6, LOW); // turn the LED on (HIGH is the voltage level)
waitForIt(190, 55, 240, 80);
}
if ((x>=250) && (x<=300)) // Button: WOHN OFF
digitalWrite(Relais6, HIGH); // turn the LED on (HIGH is the voltage level)
waitForIt(250, 55, 300, 80);
}
if ((y>=95) && (y<=120)) // Upper row
{
if ((x>=190) && (x<=240)) // Button: AUSSEN ON
{
digitalWrite(Relais3, LOW); // turn the LED on (HIGH is the voltage level)
waitForIt(190, 95, 240, 120);
}
if ((x>=250) && (x<=300)) // Button: AUSSEN OFF
digitalWrite(Relais3, HIGH); // turn the LED on (HIGH is the voltage level)
waitForIt(250, 95, 300, 120);
}
if ((y>=135) && (y<=160)) // Upper row
{
if ((x>=190) && (x<=240)) // Button: RADIO ON
{
digitalWrite(Relais4, LOW); // turn the LED on (HIGH is the voltage level)
waitForIt(190, 135, 240, 160);
}
if ((x>=250) && (x<=300)) // Button: RADIO OFF
digitalWrite(Relais4, HIGH); // turn the LED on (HIGH is the voltage level)
waitForIt(250, 135, 300, 160);
}
if ((y>=175) && (y<=200)) // Upper row
{
if ((x>=190) && (x<=240)) // Button: TERRASSE ON
{
digitalWrite(Relais7, LOW); // turn the LED on (HIGH is the voltage level)
waitForIt(190, 175, 240, 200);
}
if ((x>=250) && (x<=300)) // Button: TERRASSE OFF
digitalWrite(Relais7, HIGH); // turn the LED on (HIGH is the voltage level)
waitForIt(250, 175, 300, 200);
}
if ((y>=215) && (y<=238)) // Upper row
{
[u][i][b] if ((x>=190) && (x<=240)) // Button: UMSCHALTUNG GENERATOR / AKKU G
digitalWrite(Relais1, HIGH); // turn the LED on (LOW is the voltage level)
digitalWrite(Relais2, LOW); // turn the LED on (HIGH is the voltage level)
waitForIt(190, 215, 240, 238);
}
if ((x>=250) && (x<=300)) // Button: UMSCHALTUNG GENERATOR / AKKU A
digitalWrite(Relais1, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(Relais2, HIGH); // turn the LED on (LOW is the voltage level)
waitForIt(250, 215, 300, 238);[/b][/i][/u]
}
}
}
}
}
[EDIT] bitte den code-Tag (#) verwenden und nicht den sub-Tag. Uwe [/EDIT]