ศูนย์รวมอิเล็กทรอนิกส์แบบครบวงจร

One Stop Service Electronics

ค้นหาสินค้า พิมพ์เบอร์หรือชื่อแล้วกดค้นหา

      

 

LCD 3.5" TFT Touch Screen LCD Module 320X480 for Arduino Uno โมดูลจอแสดงผลแบบสีขนาด 3.5 นิ้ว Touch Screen + Free Stylus Pen
สินค้ามาใหม่ สินค้ายอดนิยม สินค้าแนะนำ
480.00 บาท
ติดต่อสอบถาม

โมดูลจอแสดงผลแบบสีขนาด 3.5 นิ้ว Touch Screen + Free Stylus Pen

LCD 3.5" TFT Touch LCD Module 320X480 for Arduino Uno 

Features: 3.5inch TFT LCD Module, Resolution 480x320, Controller R61581. Designed with a TF(Micro SD) card socket on the back of board so that you can conveniently insert a card. Support touch screen function. The test code is provided below. This kit requires certain professional knowledge and ability, make sure you know how to use it, please. We cannot provide any technical assistance. Specifications:

  • Driver: R61581
  • Resolution: 320X480
  • Bus : 8 Bit
  • Touch : Yes
  • Voltage: 5V/3.3V

Downloads Library  MCUFRIEND_kbv

 

CODE ตัวอย่าง

 

// the regular Adafruit "TouchScreen.h" library only works on AVRs

 

// different mcufriend shields have Touchscreen on different pins

// and rotation.

// Run the TouchScreen_Calibr_native sketch for calibration of your shield

 

#include

MCUFRIEND_kbv tft;       // hard-wired for UNO shields anyway.

#include

 

char *name = "Please Calibrate.";  //edit name of shield

const int XP=6,XM=A2,YP=A1,YM=7; //ID=0x9341

const int TS_LEFT=907,TS_RT=136,TS_TOP=942,TS_BOT=139;

 

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

TSPoint tp;

 

#define MINPRESSURE 200

#define MAXPRESSURE 1000

 

int16_t BOXSIZE;

int16_t PENRADIUS = 1;

uint16_t ID, oldcolor, currentcolor;

uint8_t Orientation = 0;    //PORTRAIT

 

// Assign human-readable names to some common 16-bit color values:

#define BLACK   0x0000

#define BLUE    0x001F

#define RED     0xF800

#define GREEN   0x07E0

#define CYAN    0x07FF

#define MAGENTA 0xF81F

#define YELLOW  0xFFE0

#define WHITE   0xFFFF

 

void show_Serial(void)

{

    Serial.println(F("Most Touch Screens use pins 6, 7, A1, A2"));

    Serial.println(F("But they can be in ANY order"));

    Serial.println(F("e.g. right to left or bottom to top"));

    Serial.println(F("or wrong direction"));

    Serial.println(F("Edit name and calibration statements\n"));

    Serial.println(name);

    Serial.print(F("ID=0x"));

    Serial.println(ID, HEX);

    Serial.println("Screen is " + String(tft.width()) + "x" + String(tft.height()));

    Serial.println("Calibration is: ");

    Serial.println("LEFT = " + String(TS_LEFT) + " RT  = " + String(TS_RT));

    Serial.println("TOP  = " + String(TS_TOP)  + " BOT = " + String(TS_BOT));

    Serial.println("Wiring is always PORTRAIT");

    Serial.println("YP=" + String(YP)  + " XM=" + String(XM));

    Serial.println("YM=" + String(YM)  + " XP=" + String(XP));

}

 

void show_tft(void)

{

    tft.setCursor(0, 0);

    tft.setTextSize(1);

    tft.print(F("ID=0x"));

    tft.println(ID, HEX);

    tft.println("Screen is " + String(tft.width()) + "x" + String(tft.height()));

    tft.println("");

    tft.setTextSize(2);

    tft.println(name);

    tft.setTextSize(1);

    tft.println("PORTRAIT Values:");

    tft.println("LEFT = " + String(TS_LEFT) + " RT  = " + String(TS_RT));

    tft.println("TOP  = " + String(TS_TOP)  + " BOT = " + String(TS_BOT));

    tft.println("\nWiring is: ");

    tft.println("YP=" + String(YP)  + " XM=" + String(XM));

    tft.println("YM=" + String(YM)  + " XP=" + String(XP));

    tft.setTextSize(2);

    tft.setTextColor(RED);

    tft.setCursor((tft.width() - 48) / 2, (tft.height() * 2) / 4);

    tft.print("EXIT");

    tft.setTextColor(YELLOW, BLACK);

    tft.setCursor(0, (tft.height() * 6) / 8);

    tft.print("Touch screen for loc");

    while (1) {

        tp = ts.getPoint();

        pinMode(XM, OUTPUT);

        pinMode(YP, OUTPUT);

        if (tp.z < MINPRESSURE || tp.z > MAXPRESSURE) continue;

        if (tp.x > 450 && tp.x < 570  && tp.y > 450 && tp.y < 570) break;

        tft.setCursor(0, (tft.height() * 3) / 4);

        tft.print("tp.x=" + String(tp.x) + " tp.y=" + String(tp.y) + "   ");

    }

}

 

 

void setup(void)

{

    uint16_t tmp;

 

    tft.reset();

    ID = tft.readID();

    tft.begin(ID);

    Serial.begin(9600);

    show_Serial();

    tft.setRotation(Orientation);

    tft.fillScreen(BLACK);

    show_tft();

 

    BOXSIZE = tft.width() / 6;

    tft.fillScreen(BLACK);

 

    tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);

    tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW);

    tft.fillRect(BOXSIZE * 2, 0, BOXSIZE, BOXSIZE, GREEN);

    tft.fillRect(BOXSIZE * 3, 0, BOXSIZE, BOXSIZE, CYAN);

    tft.fillRect(BOXSIZE * 4, 0, BOXSIZE, BOXSIZE, BLUE);

    tft.fillRect(BOXSIZE * 5, 0, BOXSIZE, BOXSIZE, MAGENTA);

 

    tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);

    currentcolor = RED;

    delay(1000);

}

 

void loop()

{

    uint16_t xpos, ypos;  //screen coordinates

    tp = ts.getPoint();   //tp.x, tp.y are ADC values

 

    // if sharing pins, you'll need to fix the directions of the touchscreen pins

    pinMode(XM, OUTPUT);

    pinMode(YP, OUTPUT);

    // we have some minimum pressure we consider 'valid'

    // pressure of 0 means no pressing!

 

    if (tp.z > MINPRESSURE && tp.z < MAXPRESSURE) {

        // most mcufriend have touch (with icons) that extends below the TFT

        // screens without icons need to reserve a space for "erase"

        // scale the ADC values from ts.getPoint() to screen values e.g. 0-239

        //

        // Calibration is true for PORTRAIT. tp.y is always long dimension 

        // map to your current pixel orientation

        switch (Orientation) {

            case 0:

                xpos = map(tp.x, TS_LEFT, TS_RT, 0, tft.width());

                ypos = map(tp.y, TS_TOP, TS_BOT, 0, tft.height());

                break;

            case 1:

                xpos = map(tp.y, TS_TOP, TS_BOT, 0, tft.width());

                ypos = map(tp.x, TS_RT, TS_LEFT, 0, tft.height());

                break;

            case 2:

                xpos = map(tp.x, TS_RT, TS_LEFT, 0, tft.width());

                ypos = map(tp.y, TS_BOT, TS_TOP, 0, tft.height());

                break;

            case 3:

                xpos = map(tp.y, TS_BOT, TS_TOP, 0, tft.width());

                ypos = map(tp.x, TS_LEFT, TS_RT, 0, tft.height());

                break;

        }

 

        // are we in top color box area ?

        if (ypos < BOXSIZE) {               //draw white border on selected color box

            oldcolor = currentcolor;

 

            if (xpos < BOXSIZE) {

                currentcolor = RED;

                tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);

            } else if (xpos < BOXSIZE * 2) {

                currentcolor = YELLOW;

                tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, WHITE);

            } else if (xpos < BOXSIZE * 3) {

                currentcolor = GREEN;

                tft.drawRect(BOXSIZE * 2, 0, BOXSIZE, BOXSIZE, WHITE);

            } else if (xpos < BOXSIZE * 4) {

                currentcolor = CYAN;

                tft.drawRect(BOXSIZE * 3, 0, BOXSIZE, BOXSIZE, WHITE);

            } else if (xpos < BOXSIZE * 5) {

                currentcolor = BLUE;

                tft.drawRect(BOXSIZE * 4, 0, BOXSIZE, BOXSIZE, WHITE);

            } else if (xpos < BOXSIZE * 6) {

                currentcolor = MAGENTA;

                tft.drawRect(BOXSIZE * 5, 0, BOXSIZE, BOXSIZE, WHITE);

            }

 

            if (oldcolor != currentcolor) { //rub out the previous white border

                if (oldcolor == RED) tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);

                if (oldcolor == YELLOW) tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW);

                if (oldcolor == GREEN) tft.fillRect(BOXSIZE * 2, 0, BOXSIZE, BOXSIZE, GREEN);

                if (oldcolor == CYAN) tft.fillRect(BOXSIZE * 3, 0, BOXSIZE, BOXSIZE, CYAN);

                if (oldcolor == BLUE) tft.fillRect(BOXSIZE * 4, 0, BOXSIZE, BOXSIZE, BLUE);

                if (oldcolor == MAGENTA) tft.fillRect(BOXSIZE * 5, 0, BOXSIZE, BOXSIZE, MAGENTA);

            }

        }

        // are we in drawing area ?

        if (((ypos - PENRADIUS) > BOXSIZE) && ((ypos + PENRADIUS) < tft.height())) {

            tft.fillCircle(xpos, ypos, PENRADIUS, currentcolor);

        }

        // are we in erase area ?

        // Plain Touch panels use bottom 10 pixels e.g. > h - 10

        // Touch panels with icon area e.g. > h - 0

        if (ypos > tft.height() - 10) {

            // press the bottom of the screen to erase

            tft.fillRect(0, BOXSIZE, tft.width(), tft.height() - BOXSIZE, BLACK);

        }

    }

 

}

เลือกสินค้าและสั่งซื้อผ่าน AgeBKK คลิ๊ก

 

 

ปิดปรับปรุงระบบความคิดเห็นชั่วคราว ขออภัยในความไม่สะดวก หากลูกค้าต้องการเปิดใช้งานระบบ กรุณาติดต่อ 02-8323222 กด 2