질문게시판 > 답변 : TFT LCD 버튼값 출력하기 2번째 질문입니다! 제발 도와주세요ㅠㅠ

TODAY204 TOTAL2,696,083
사이트 이용안내
Login▼/회원가입
최신글보기 질문게시판 기술자료 동영상강좌

아두이노 센서 ATMEGA128 PWM LED 초음파 AVR 블루투스 LCD UART 모터 적외선


BASIC4MCU | 질문게시판 | 답변 : TFT LCD 버튼값 출력하기 2번째 질문입니다! 제발 도와주세요ㅠㅠ

페이지 정보

작성자 master 작성일2020-03-01 10:42 조회20,904회 댓글5건

본문

	

 

// DateTime : 2020-03-01 오전 10:44:20
// by Ok-Hyun Park
//
#include <MCUFRIEND_kbv.h>
#include <Adafruit_GFX.h>// Core graphics library
// wiring with UNO or Mega2560:
//--------------POWER Pins--------------------------------
//   5V  connects to DC 5V
//   GND connects to Ground
//   3V3 do not need to connect(NC)
//--------------LCD Display Pins--------------------------
//   LCD_RD   connects to Analog pin A0
//   LCD_WR   connects to Analog pin A1
//   LCD_RS   connects to Analog pin A2
//   LCD_CS   connects to Analog pin A3
//   LCD_RST  connects to Analog pin A4
//   LCD_D0   connects to digital pin 8
//   LCD_D1   connects to digital pin 9
//   LCD_D2   connects to digital pin 2
//   LCD_D3   connects to digital pin 3
//   LCD_D4   connects to digital pin 4
//   LCD_D5   connects to digital pin 5
//   LCD_D6   connects to digital pin 6
//   LCD_D7   connects to digital pin 7
//--------------SD-card fuction Pins----------------------
//This Connection Only for UNO,Do not support Mega2560
//because they use different Hardware-SPI Pins
//SD_SS    connects to digital pin 10
//SD_DI    connects to digital pin 11
//SD_DO    connects to digital pin 12
//SD_SCK   connects to digital pin 13
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
#define LCD_CS    A3   // Chip Select goes to Analog 3
#define LCD_CD    A2  // Command/Data goes to Analog 2
#define LCD_WR    A1  // LCD Write goes to Analog 1
#define LCD_RD    A0 // LCD Read goes to Analog 0
//
#define Button_pin 33
//
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF
//
MCUFRIEND_kbv   tft;
//
void disp(){
  tft.setCursor(0,0); tft.setTextColor(WHITE); tft.setTextSize(3);
  tft.println("Push the Button");
  tft.print("value: "); tft.println(Button_value);
}
//
int Button_value=0,Button_flag=0;
//
void setup(void){
  Serial.begin(9600); Serial.println(F("TFT LCD test"));
  tft.reset();
  uint16_t identifier=tft.readID();
  if     (identifier==0x9325){ Serial.println(F("Found ILI9325 LCD driver ")); }
  else if(identifier==0x9328){ Serial.println(F("Found ILI9328 LCD driver ")); }
  else if(identifier==0x4535){ Serial.println(F("Found LGDP4535 LCD driver")); }
  else if(identifier==0x7575){ Serial.println(F("Found HX8347G LCD driver ")); }
  else if(identifier==0x9595){ Serial.println(F("Found HX8347-I LCD driver")); }
  else if(identifier==0x4747){ Serial.println(F("Found HX8347-D LCD driver")); }
  else if(identifier==0x8347){ Serial.println(F("Found HX8347-A LCD driver")); }
  else if(identifier==0x9341){ Serial.println(F("Found ILI9341 LCD driver ")); }
  else if(identifier==0x7783){ Serial.println(F("Found ST7781 LCD driver  ")); }
  else if(identifier==0x8230){ Serial.println(F("Found UC8230 LCD driver  ")); }
  else if(identifier==0x8357){ Serial.println(F("Found HX8357D LCD driver ")); }
  else if(identifier==0x0101){ Serial.println(F("Found 0x9341 LCD driver  ")); identifier=0x9341; }
  else if(identifier==0x7793){ Serial.println(F("Found ST7793 LCD driver  ")); }
  else if(identifier==0xB509){ Serial.println(F("Found R61509 LCD driver  ")); }
  else if(identifier==0x9486){ Serial.println(F("Found ILI9486 LCD driver ")); }
  else if(identifier==0x9488){ Serial.println(F("Found ILI9488 LCD driver ")); }
  else                       { Serial.print(F("Unknown LCD driver chip: ")); Serial.println(identifier,HEX); identifier=0x9486; }
  tft.begin(identifier);
  disp();
}
//
void loop(void){
  if(digitalRead(Button_pin)){
    if(Button_flag){ Button_flag=0;
      Button_value++; Serial.print("value: "); Serial.println(Button_value);
      disp();
      delay(100);
    }
  }
  else{
    if(Button_flag==0){ Button_flag=1delay(100); }
  }
}

 

  • BASIC4MCU 작성글 SNS에 공유하기
  • 페이스북으로 보내기
  • 트위터로 보내기
  • 구글플러스로 보내기

댓글 5

조회수 20,904

쉘쉘김쉘쉘님의 댓글

쉘쉘김쉘쉘 작성일

C:\Users\scjin\Desktop\naver1\___1\___1.ino: In function 'void disp()':
___1:49:23: error: 'lcd' was not declared in this scope
  tft.setCursor(0,0); lcd.setTextColor(WHITE); lcd.setTextSize(3);
                      ^
___1:51:37: error: 'Button_value' was not declared in this scope
  lcd.print("value: "); lcd.println(Button_value);
                                    ^
C:\Users\scjin\Desktop\naver1\___1\___1.ino: In function 'void loop()':
___1:80:8: error: 'Button_flag' was not declared in this scope
    if(Button_flag){ Button_flag=0;
        ^
___1:81:7: error: 'Button_value' was not declared in this scope
      Button_value++; Serial.print("value: "); Serial.println(Button_value);
      ^
___1:87:8: error: 'Button_flag' was not declared in this scope
    if(Button_flag==0){ Button_flag=1; delay(100); }
        ^
exit status 1
'lcd' was not declared in this scope

컴파일 하니까 이런 오류가 생기네요..
1. 'lcd'부분은 'tft'로 변경하면 되는지
2. Button_flag 부분은 어떻게 해야하는지
질문 드립니다ㅜㅜ

master님의 댓글

master 댓글의 댓글 작성일

간단한 오류는 수정할 수 있어야합니다.
다시 복사해서 돌려보세요

쉘쉘김쉘쉘님의 댓글

쉘쉘김쉘쉘 작성일

이부분은 덕분에 수정해서 성공했습니다.

추가 질문으로 버튼 값이 아니고
조도센서 값이 예를들어 700 이상이면

숫자 값이 1씩 올라가게 표현하려면 어떻게 해야할까요?

밝기에 따른 조도센서 값을 lcd에 표현하는건 할 수 있는데 값이 아니라
일정 값 이상일 때 숫자가 1씩 올라가는..

master님의 댓글

master 작성일

int mode=0;
//
void loop(void){
  int a=analogRead(A0);
  if(a>700){
    if(mode!=1){ mode=1;
      Button_value++; Serial.print("value: "); Serial.println(Button_value);
      disp();
    }
  }
  else if(a>650){} // 650~700
  else{
    if(mode!=-1){ mode=-1; }
  }
}
여기서
아나로그 값은 일정부분 흔들림이 있는데 700 근처에서 값이 흔들리게 되면 카운트가 계속 증가하게 됩니다.
  else if(a>650){} // 650~700
만약 흔들림의 크기가 최대 50 미만이라면 650~700 범위는 오차로 보고서 아무런 처리를 하지 않도록 하면 됩니다.

쉘쉘김쉘쉘님의 댓글

쉘쉘김쉘쉘 작성일

ㄱㅅ합니다.
추가 의문점이 두개 있는데요
1. 혹시 아두이노내에서
 디지털 1번핀과 2번핀을 직접 전선으로
 연결해서
 디지털 1번핀이 내보내는 신호를
  디지털 2번핀이 입력받을 수 있나요?
  불 안날까요?

2. 소스코드를 푸시버튼을 눌렀을 시 숫자
  값이 1씩 올라가도록한 상태에서,
  푸시버튼을 대신
  디지털 신호를 보내도 작동 될까요?

확인하고 싶은게

회로를 디지털 1번핀과 2번핀으로 직접
연결한 상태에서, (2번 핀은 버튼입력 시
숫자값이 올라가는 소스코드를 해둘겁니다.)

이때,
먼저, 아날로그 1번핀(조도센서) 값이
          700 이상일 때 디지털 1번핀으로
        신호를 내보내도록 하고,

디지털 1번핀의 출력신호를 디지털 2번 핀이 입력받아 (푸시버튼을 대체한) 숫자값이 올라가도록 하고싶은데

가능할까요?

질문게시판HOME > 질문게시판 목록

MCU, AVR, 아두이노 등 전자공학에 관련된 질문을 무료회원가입 후 작성해주시면 전문가가 답변해드립니다.
ATMEGA128PWMLED초음파
아두이노AVR블루투스LCD
UART모터적외선ATMEGA
전체 스위치 센서
질문게시판 목록
제목 작성자 작성일 조회
공지 MCU, AVR, 아두이노 등 전자공학에 관련된 질문은 질문게시판에서만 작성 가능합니다. 스태프 19-01-15 19664
공지 사이트 이용 안내댓글[28] master 17-10-29 34155
질문 아두이노 리니어 제어 모듈 설계중입니다. 도와주세요 새글 갓비타 23-06-06 15
질문 dc모터 제어 관련 질문 드려요 ㅠㅠ!! 새글 dpwl 23-06-06 15
질문 pixy2 cam 을 이용한 색상인식 모터 제어 새글 가나다라 23-06-05 13
질문 안녕하세요 제품 품목 이름에 대해서 궁금합니다. 이미지새글첨부파일 알려주시면감사합니다 23-06-05 18
질문 Atmega128 온도센서로 led제어 질문드려요 이미지새글첨부파일 얍얍 23-06-05 23
질문 아구이노 코드를 atmega 128 코드로 변환 하고 싶습니다 ㅠㅠ 새글 기로롱 23-06-05 22
질문 atmega128 uart 질문입니다. bme12 23-06-05 23
질문 라즈베리파이에 풀 프레임 이미지센서 활용에 대한 질문이 있습니다. 이미지첨부파일 KYLO 23-06-04 19
질문 아두이노 시리얼 번호를 이용해 led 제어 wnion 23-06-04 21
질문 ATMEGA128 혹시 여기서 왜 인터럽트 기능이 안되는지 알 수 있나요 IEEE 23-06-04 33
질문 stm32f767을 이용해서 자이로가속도 센서의 값 받아오기 rlchwjswk 23-06-03 22
질문 아두이노 모터제어 관련해서 질문드립니다!댓글[1] 이미지첨부파일 아두이노어렵잖아 23-06-03 46
질문 atmega128 디지털조도센서 코드오류댓글[1] 이미지 까미 23-06-02 41
질문 atmega128 디지털 조도 센서댓글[1] 까미 23-06-02 41
질문 적외선리모콘으로 부저를제어 하는방법 질문입니다.댓글[4] Tell 23-06-02 24
질문 lora 무선 모듈에 관한 질문입니다.댓글[1] 로이스10 23-06-01 22
질문 적외선 송수신기 DC모터2개 제어 질문입니다.댓글[5] Tell 23-06-01 40
질문 스텝모터 제어 코드 질문댓글[5] pmh11 23-05-31 46
질문 초음파 센서를 이용한 인원 카운팅댓글[1] 초음파야 23-05-31 38
질문 모터 Hall 스위치 연결 문의댓글[1] 오후 23-05-31 26
질문 아두이노 lcd 문자 스크롤디스플레이 wnion 23-05-31 34
답변 답변글 답변 : 아두이노 lcd 문자 스크롤디스플레이댓글[1] master 23-05-31 34
질문 아두이노 타이머 인터럽트 미ㅏㄴㅇ 23-05-30 48
답변 답변글 답변 : 아두이노 타이머 인터럽트댓글[7] master 23-05-30 55
질문 THC-Soil Sensor with TTL 모듈 아두이노 센서값 받아오기댓글[1] ppiickle 23-05-30 34
질문 stm32 psd센서구동 질문댓글[2] 수포자 23-05-29 31
질문 앱인벤터 아두이노 보드 LCD 글씨 나타내기 질문댓글[7] 이미지 당찬병아리 23-05-29 49
질문 atmega128 led와 fan댓글[3] 이라 23-05-28 56
게시물 검색

2022년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2021년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2020년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2019년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2018년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
Privacy Policy
MCU BASIC ⓒ 2020
모바일버전으로보기