Hi everyone , I bought this LCD Touch :
sito venditore
I'm using these libraries :
sito librerie
I'm writing an application to control the motors . My goal is that by pressing a button, the motor starts up until I remove my finger (well , a simple button ) .
I writre this code:
// UTFT_Buttons_Demo_320x240
void loop()
{
int but1, but2, but3, pressed_button;
boolean default_colors = true;but1 = myButtons.addButton( 10, 10, 80, 80, "Z+");
but2 = myButtons.addButton( 90, 10, 80, 80, "Z-");
but3 = myButtons.addButton( 170, 10, 80, 80, "R-");
myButtons.drawButtons();myGLCD.print("You pressed:", 110, 205);
myGLCD.setColor(VGA_BLACK);
myGLCD.setBackColor(VGA_WHITE);
myGLCD.print("None ", 110, 220);
while(1){
if (myTouch.dataAvailable() == true)
{
Serial.print("Avvio");
Serial.println("");
pressed_button = myButtons.checkButtons();
if(pressed_button==but1){
z++;
myGLCD.print("Alza ", 110, 220);
ValoreZ = String(z);
stringaUno = String(ValoreZ + "\t" + ValoreR);
Serial.print(stringaUno);
Serial.println("");
}
if (pressed_button==but2){
myGLCD.print("Abbassa", 110, 220);
z--;
ValoreZ = String(z);
stringaUno = String(ValoreZ + "\t" + ValoreR);
Serial.print(stringaUno);
Serial.println("");
}
if (pressed_button==but3){
myGLCD.print("Ruota ", 110, 220);
r++;
ValoreR = String(r);
stringaUno = String(ValoreZ + "\t" + ValoreR);
Serial.print(stringaUno);
Serial.println("");
}
if (pressed_button==-1)
myGLCD.print("None ", 110, 220);
}
}
}
with the code
if (myTouch.dataAvailable() == true)
Arduino checks whether there has been a change in the sensors ( then a touch )
while with this :
if(pressed_button==but1)
The “if” is executed when the button is released .
Now I wish that the trade is made at the touch of the button and the motor moves until I remove the finger
Thanks,
Ivan