#include
#include
#include
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GRREN 0x07E0
#define CYAN 0x07FFg
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
void TFT_INIT(){
tft.reset();
tft.begin(38017);
tft.setRotation(1);
}
void SERIAL_INIT(){
Serial.begin(9600);
while(!Serial){}
}
void setup(){
Serial.begin(9600);
SERIAL_INIT();
TFT_INIT();
SPI.begin();
while(!Serial);
}
void loop() {
char data;
int Press =analogRead(A0)-100;
Serial.print("<");
Serial.print(Press);
Serial.print(">\n");
while(Serial.available()){
byte data1 = Serial.read();
}
while(Serial.available()){
data = Serial.read();
Serial.print(data);
}
tft.fillScreen(WHITE);
tft.setCursor(3,20);
tft.setTextColor(BLACK);
tft.setTextSize(6);
tft.print("This seat is pregnant women's seat.");
delay(1500);
if(data1=='Hello, Pregnant Woman!!1'){
tft.fillScreen(WHITE);
tft.setCursor(3,20);
tft.setTextColor(BLACK);
tft.setTextSize(6);
tft.print("Wellcome pregnant woman!");
}
if(data1 =='Hello, Pregnant Woman!!'){
tft.fillScreen(WHITE);
tft.setCursor(3,20);
tft.setTextColor(BLACK);
tft.setTextSize(6);
tft.print("Wellcome pregnant woman!");
}
if(Press>990&&Press<1025){
tft.fillScreen(WHITE);
tft.setCursor(3,20);
tft.setTextColor(BLACK);
tft.setTextSize(6);
tft.print("if you are a pregnant woman, Please recognize your [pregnant badge] this body.");
delay(2000);
}
}
이런 식으로 만들었는데 왜 자꾸 애러가 data1에서 뜨죠? ㅠㅠ 왜그런지 모르겠어서 올립니다.
시리얼을 어떻게 읽을 수 있을까요?
|