Control relays with buttons on TFT Screen

Looking for a little help with making this work.

Equipment:

1 x Uno
2 x Relay Shields
1 x TFT Shield

Relays are wired to digital ports 0,1,2,3,8,9,10 + Power

TFT using digital ports 4,5,6,7,11,12,13

Quick explanation I would like to have a TFT 8 button keypad to switch 7 of the 8 relay banks from on to off with a single press. Stay on till turned off or till Uno power cycles. Buttons change color from green to red. Button 8 on Keypad would trigger all 7 banks to switch with one push. I have some of code the I have been working on below. I only has the buttons drawn and relays pinned out. I need help with the touch push to trigger state change in button and relays to do the switching. Any help would be greatly accepted. Thanks in advanced.

CarKeyPad2.2.ino (4.33 KB)

The code you attached

with the excessive amount

of white space does nothing useful.

YOU need to, in loop(), determine which button(s) are pressed, and do something to the corresponding relay.

I was let to believe this group was full of helpful intelligent people. Unfortunately the first and only response was useless and provided by a smarta$$. Please in future if you plan to respond to a post you should have a little more respect and at least provide an example or something to to start with. I'm part of a few online groups and programmer are always the toughest to get quality info from because there human interaction is limited. Learning something new is hard enough with out dealing with someone that is ...... well. Moving on I hope spacing between my lines in this response was sufficient for your eyes to comprehend. Please don't do me any favors and respond to my post.

Thank You and have a great day.

ESILVA

Please don't do me any favors and respond to my post.

OK, I won't. You might take a peak at my signature, though, and consider it in light of the information you provided.

NewbiCoder:
I was let to believe this group was full of helpful intelligent people.

It is.
If you really want help, you post your code, not attach it.

It's all explained in the clearly-posted stickies.

Not PAULS version sheesh...

* /
#include <SeeedTouchScreen.h>
#include <stdint.h>
#include <TFTv2.h>
#include <SPI.h>

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


int switch1Color = 0;//Test
int switch2Color = 0;//Test
int switch3Color = 0;//Test
int switch4Color = 0;//Test


#define relay1 0
#define relay2 1
#define relay3 2
#define relay4 3
#define relay5 8
#define relay6 9
#define relay7 10

void setup() {

  pinMode(relay1, OUTPUT);// connected to Relay 1
  pinMode(relay2, OUTPUT);// connected to Relay 2
  pinMode(relay3, OUTPUT);// connected to Relay 3
  pinMode(relay4, OUTPUT);// connected to Relay 4
  pinMode(relay5, OUTPUT);// connected to Relay 5
  pinMode(relay6, OUTPUT);// connected to Relay 6
  pinMode(relay7, OUTPUT);// connected to Relay 7


  // Ref Only
  //digitalWrite(relay1,HIGH);
  //digitalWrite(relay2,HIGH);
  //digitalWrite(relay3,HIGH);
  //digitalWrite(relay4,HIGH);
  //digitalWrite(relay5,HIGH);
  //digitalWrite(relay6,HIGH);
  //digitalWrite(relay7,HIGH);

  //digitalWrite(relay1,LOW);
  //digitalWrite(relay2,LOW);
  //digitalWrite(relay3,LOW);
  //digitalWrite(relay4,LOW);
  //digitalWrite(relay5,LOW);
  //digitalWrite(relay6,LOW);
  //digitalWrite(relay7,LOW);

  TFT_BL_ON;                                          //turn on the background light

  Tft.TFTinit();                                      //init TFT library






  Tft.fillRectangle(0, 0, 120, 70, GREEN); //ditch
  digitalWrite(relay1, HIGH);

  Tft.fillRectangle(0, 0, 120, 70, RED); //ditch
  digitalWrite(relay1, LOW);





  Tft.fillRectangle(0, 70, 120, 70, GREEN); //back
  digitalWrite(relay2, HIGH);

  Tft.fillRectangle(0, 70, 120, 70, RED); //back
  digitalWrite(relay2, LOW);


  Tft.fillRectangle(0, 140, 120, 70, GREEN); //aux1
  digitalWrite(relay3, HIGH);

  Tft.fillRectangle(0, 140, 120, 70, RED); //aux1
  digitalWrite(relay3, LOW);


  Tft.fillRectangle(0, 210, 120, 70, GREEN); //aux2
  digitalWrite(relay4, HIGH);

  Tft.fillRectangle(0, 210, 120, 70, RED); //aux2
  digitalWrite(relay4, LOW);


  Tft.fillRectangle(121, 0, 120, 70, GREEN); //bar1
  digitalWrite(relay5, HIGH);

  Tft.fillRectangle(121, 0, 120, 70, RED); //bar1
  digitalWrite(relay5, LOW);


  Tft.fillRectangle(121, 70, 120, 70, GREEN); //bar2
  digitalWrite(relay6, HIGH);

  Tft.fillRectangle(121, 70, 120, 70, RED); //bar2
  digitalWrite(relay6, LOW);


  Tft.fillRectangle(121, 140, 120, 70, GREEN); //aux3
  digitalWrite(relay7, HIGH);

  Tft.fillRectangle(121, 140, 120, 70, RED); //aux3
  digitalWrite(relay7, LOW);


  Tft.fillRectangle(121, 210, 120, 70, GREEN); //all
  digitalWrite(relay1 - 7, HIGH);

  Tft.fillRectangle(121, 210, 120, 70, RED); //all
  digitalWrite(relay1 - 7, LOW);



  // Borders around buttons

  Tft.drawRectangle(0, 0, 120, 70, WHITE); //ditch
  Tft.drawRectangle(0, 70, 120, 70, WHITE); //back
  Tft.drawRectangle(0, 140, 120, 70, WHITE); //aux1
  Tft.drawRectangle(0, 210, 120, 70, WHITE); //aux2

  Tft.drawRectangle(0, 295, 240, 30, WHITE); //bbar

  Tft.drawRectangle(121, 0, 120, 70, WHITE); //bar1
  Tft.drawRectangle(121, 70, 120, 70, WHITE); //bar2
  Tft.drawRectangle(121, 140, 120, 70, WHITE); //aux3
  Tft.drawRectangle(121, 210, 120, 70, WHITE); //all



  //Name on bottom of TP

  Tft.drawString("LIGHTS & AUX", 5, 300, 2, WHITE); //bbar



  //Names on Buttons Here

  Tft.drawString("Ditch:", 10, 10, 2, BLACK); //ok
  Tft.drawString("Back:", 10, 80, 2, BLACK); //ok

  Tft.drawString("Bar 1:", 130, 10, 2, BLACK); //ok
  Tft.drawString("Bar 2:", 130, 80, 2, BLACK); //ok

  Tft.drawString("Aux 1:", 10, 150, 2, BLACK); //ok
  Tft.drawString("Aux 2:", 10, 220, 2, BLACK); //ok

  Tft.drawString("Aux 3:", 130, 150, 2, BLACK); //ok
  Tft.drawString("ALL:", 130, 220, 2, BLACK); //ok








}

void loop()
{

}

/*********************************************************************************************************
  END FILE
*********************************************************************************************************/