for a science project and to test people if they can recognize vibrations with the fingertips.
I am trying to program a ILI9431 2.4inch tft display without the blinking.
Problem: What i am trying to do and where I get stuck in the following Void loop.
Program function:
input voltage A0=0V Yellow screen with a large white Zero in the center// ok works and without blink
input voltage A0=1.5V Red screen with a large white One in the center wait for a vibration 1//starts blinking
input voltage A0=3.3V Blue screen with a large white Two in the center wait for a vibration 2 //starts blinking
Press button red or blue
go back to screen Yellow show a large white Zero and wait for another signal from labchart.
I can switch from Yellow to each and the other colours, but how do I stop the blinking? if I make a transistion from Yellow to red the 1 starts blinking I really dont have a clue, do I use pointers?
down below is the attached program. I clearly have some fundamental problems with how this can be done. therefore help is greatly appreciated.
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
// For the Adafruit shield, these are the default.
#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
int center_x=110;
int center_y=50;
int Fsize=20;
//void loop steps
int prevX=0; //Yellow
//int prevX1=512; //Red
//int prevX2=1023; //Blue
int prevcounti=0;
//steps numbers screen
void setup()
{
Serial.begin(9600);
tft.begin();
tft.setRotation(3);
tft.setCursor(150,100);
tft.fillScreen(ILI9341_YELLOW);
}
void loop(void)
{
int input=analogRead(A0);
Serial.print("input ");
Serial.print(input);
delay(10);
if(input!=prevX)//0
{
TextInfront();// call this function to get to the tft.print("0") to switch it on
// should i give a parameter to this function? how? pointers?
}
else
{
TextInfront();// call this function to get to the tft.print("0") to switch it off
}
Serial.print("Prev X ");
Serial.println(prevX);
delay(1000);
int prevX=input;
}
//--------------------step 1 display shows Zero
void TextInFront()
{ int counti=0;
Serial.print("counti ");
Serial.println(counti);
if(counti!=prevcounti)
{
tft.setCursor(center_x,center_y);
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(Fsize);
tft.println("0");
counti++;
}
else
{
tft.println("");
}
prevcounti=counti;
}
help is greatly appreciated.
sincerely yours
Bastiaan
I am trying to program a ILI9431 2.4inch tft display without the blinking.
Problem: What i am trying to do and where I get stuck in the following Void loop.
Program function:
input voltage A0=0V Yellow screen with a large white Zero in the center// ok works and without blink
input voltage A0=1.5V Red screen with a large white One in the center wait for a vibration 1//starts blinking
input voltage A0=3.3V Blue screen with a large white Two in the center wait for a vibration 2 //starts blinking
Press button red or blue
go back to screen Yellow show a large white Zero and wait for another signal from labchart.
I can switch from Yellow to each and the other colours, but how do I stop the blinking? if I make a transistion from Yellow to red the 1 starts blinking I really dont have a clue, do I use pointers?
down below is the attached program. I clearly have some fundamental problems with how this can be done. therefore help is greatly appreciated.
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
// For the Adafruit shield, these are the default.
#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
int center_x=110;
int center_y=50;
int Fsize=20;
//void loop steps
int prevX=0; //Yellow
//int prevX1=512; //Red
//int prevX2=1023; //Blue
int prevcounti=0;
//steps numbers screen
void setup()
{
Serial.begin(9600);
tft.begin();
tft.setRotation(3);
tft.setCursor(150,100);
tft.fillScreen(ILI9341_YELLOW);
}
void loop(void)
{
int input=analogRead(A0);
Serial.print("input ");
Serial.print(input);
delay(10);
if(input!=prevX)//0
{
TextInfront();// call this function to get to the tft.print("0") to switch it on
// should i give a parameter to this function? how? pointers?
}
else
{
TextInfront();// call this function to get to the tft.print("0") to switch it off
}
Serial.print("Prev X ");
Serial.println(prevX);
delay(1000);
int prevX=input;
}
//--------------------step 1 display shows Zero
void TextInFront()
{ int counti=0;
Serial.print("counti ");
Serial.println(counti);
if(counti!=prevcounti)
{
tft.setCursor(center_x,center_y);
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(Fsize);
tft.println("0");
counti++;
}
else
{
tft.println("");
}
prevcounti=counti;
}
help is greatly appreciated.
sincerely yours
Bastiaan