배송 |
---|
상품 정보 | 가격 | 삭제 |
---|---|---|
아두이노 1.8인치 128x160 TFT LCD 모듈 | ||
TOTAL PRICE(수량) 0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include <TFT.h> // 아두이노 LCD 라이브러리 포함 #include <SPI.h> // 아두이노 SPI 라이브러리 포함 #define cs 10 // CS를 10번 핀에 #define dc 9 // DC or A0를 9번 핀에 #define rst 8 // RESET은 8번 핀에 TFT TFTscreen = TFT(cs, dc, rst); // TFT 클래스 생성 char sensorPrintout[4]; // 센서 값을 저장할 변수 void setup() { TFTscreen.begin(); // TFT 클래스 시작 TFTscreen.background(0, 0, 0); // 검정색으로 화면 초기화 TFTscreen.stroke(255, 255, 255); // 폰트 색깔 흰색으로 설정 TFTscreen.setTextSize(2); // 폰트 크기 2로 설정 TFTscreen.text("Sensor Value :\n ", 0, 0); // LCD에 글씨 표시 TFTscreen.setTextSize(5); // 폰트 크기 5로 설정 } void loop() { String sensorVal = String(analogRead(A0)); // A0의 값을 받아와서 문자열 변수에 저장 sensorVal.toCharArray(sensorPrintout, 4); // 읽어온 센서 문자열 변수를 가지고 각각의 캐릭터 변수에 저장 TFTscreen.stroke(150, 0, 150); // 폰트 색깔 설정 TFTscreen.text(sensorPrintout, 0, 20); // LCD X:0, Y:20 위치에 글씨 표시 delay(250); // 250ms 기다림 TFTscreen.stroke(0, 0, 0); // 글씨체 검정색으로 TFTscreen.text(sensorPrintout, 0, 20); // 화면에서 안보이게 하기 위해 검정색으로 표시함 } | cs |