chiedo scusa per il doppio post ma il codice è lungo e non avevo alternaitive
e il codice del dysplay che ho è questo:
// UTFT_Buttons_Demo_320x240
// Copyright (C)2016 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// A small demo to demonstrate the use of some of the
// functions of the UTFT_Buttons add-on library.
//
// This demo was made for modules with a screen resolution
// of 320x240 pixels, but should work on larger screens as
// well.
//
// This program requires both the UTFT and URTouch libraries
// in addition to the UTFT_Buttons add-on library.
//
#include <UTFT.h>
#include <URTouch.h>
#include <UTFT_Buttons.h>
// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t Dingbats1_XL[];
// Set up UTFT...
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino 2009/Uno/Leonardo shield : <display model>,19,18,17,16
// Standard Arduino Mega/Due shield : <display model>,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Due : <display model>,25,26,27,28
// Standard chipKit Uno32/uC32 : <display model>,34,35,36,37
// Standard chipKit Max32 : <display model>,82,83,84,85
// AquaLEDSource All in One Super Screw Shield : <display model>,82,83,84,85
// CC3200 LaunchPad (pins used in the examples): <display model>,15,18,11,32
//
// Remember to change the model parameter to suit your display module!
UTFT myGLCD(ILI9341_16, 38, 39, 40, 41);
// Set up URTouch...
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino 2009/Uno/Leonardo shield : 15,10,14,9,8
// Standard Arduino Mega/Due shield : 6,5,4,3,2
// CTE TFT LCD/SD Shield for Arduino Due : 6,5,4,3,2
// Standard chipKit Uno32/uC32 : 20,21,22,23,24
// Standard chipKit Max32 : 62,63,64,65,66
// AquaLEDSource All in One Super Screw Shield : 62,63,64,65,66
// CC3200 LaunchPad (pins used in the examples): 31,13,19,28,17
//
URTouch myTouch(6, 5, 4, 3, 2);
// Finally we set up UTFT_Buttons :)
UTFT_Buttons myButtons(&myGLCD, &myTouch);
int contatore1 = 0;
int semaforo = 0;
int statosensore1 = 0; // variabile di memorizzazione dello stato (LOW oppure HIGH) del
// modulo keyesir
#define sensore1 14 // il pin "out" del modulo keyesir e' collegato alla porta 7
int pressed_button
void setup()
{
myGLCD.InitLCD();
myGLCD.clrScr();
myGLCD.setFont(BigFont);
myTouch.InitTouch();
myTouch.setPrecision(PREC_MEDIUM);
myButtons.setTextFont(BigFont);
myButtons.setSymbolFont(Dingbats1_XL);
Serial.begin(9600); // inizializza il monitor seriale
pinMode (sensore1, INPUT);// il sensore viene definito come unita' di input
}
void loop()
{
if (pressed_button == but1)
myGLCD.print ( Serial.println(contatore1);
statosensore1 = digitalRead (sensore1); // rileva lo stato del modulo
if (statosensore1 == HIGH) // se non ci sono ostacoli
semaforo = 0; // spegne il semaforo in modo da predisporsi alla conta
// del prossimo ostacolo
if ((semaforo == 0) && (statosensore1 == LOW)) // se c'e' un nuovo ostacolo non conteggiato
{
semaforo = 1; // considera conteggiato l'ostacolocontatore1 = contatore1 + 1; // conteggia l'ostacolo
Serial.println(contatore1);
int but1, but2, but3, but4, but5, but6, but7, but8, butY, pressed_button;
boolean default_colors = true;
but1 = myButtons.addButton( 0, 20, 75, 70, "1");
but2 = myButtons.addButton( 80, 20, 75, 70, "2");
but3 = myButtons.addButton( 160, 20, 75, 70, "3");
but4 = myButtons.addButton( 240, 20, 75, 70, "4");
but5 = myButtons.addButton( 0, 100, 75, 70, "5");
but6 = myButtons.addButton( 80, 100, 75, 70, "6");
but7 = myButtons.addButton( 160, 100, 75, 70, "7");
but8 = myButtons.addButton( 240, 100, 75, 70, "8");
butY = myButtons.addButton( 0, 199, 100, 40, "reset");
myButtons.drawButtons();
myGLCD.print("", 110, 205);
myGLCD.setColor(VGA_BLACK);
myGLCD.setBackColor(VGA_WHITE);
while (1)
{
if (myTouch.dataAvailable() == true)
{
pressed_button = myButtons.checkButtons();
{
}
} else if (pressed_button == butY)
{
if (default_colors)
{
myButtons.setButtonColors(VGA_YELLOW, VGA_RED, VGA_YELLOW, VGA_BLUE, VGA_GRAY);
myButtons.relabelButton(butY, "_");
myButtons.drawButtons();
default_colors = false;
}
else
{
myButtons.setButtonColors(VGA_WHITE, VGA_GRAY, VGA_WHITE, VGA_RED, VGA_BLUE);
myButtons.relabelButton(butY, "I");
myButtons.drawButtons();
default_colors = true;
}
}
if (pressed_button == but1)
myGLCD.print("contatore", 110, 220);
if (pressed_button == but2)
myGLCD.print("int contatore" , 110, 220);
if (pressed_button == but3)
myGLCD.print("int contatore", 110, 220);
if (pressed_button == but4)
myGLCD.print("contatore", 110, 220);
if (pressed_button == but5)
myGLCD.print("contatore", 110, 220);
if (pressed_button == but6)
myGLCD.print("contatore", 110, 220);
if (pressed_button == but7)
myGLCD.print("contatore", 110, 220);
if (pressed_button == but8)
myGLCD.print("contatore", 110, 220);
}
}
}
aiuti?