1.44 Zoll TFT LCD Display

Inhalt

Beispiele für die Verwendung von TFT-Displays

Anschluss an den Arduino

Benötigte Bibliotheken

Suche im Bibliotheksverwalter
Sketch -> Biblio­thek ein­bin­den -> Biblio­the­ken verwalten
oder über das entsprechende Icon nach der Bibliothek Adafruit ST7735.
Anschließend musst in der nächsten Dialogbox die zusätzlichen Bibliotheken installieren.

Funktionen der Bibliothek Adafruit ST77735

Das Programm im Film

Der Programmcode

				
					// Pins zuordnen
# define TFT_PIN_CS 10
# define TFT_PIN_DC 9
# define TFT_PIN_RST 8

// Bibliotheken einbinden
# include "SPI.h"
# include "Adafruit_GFX.h"
# include "Adafruit_ST7735.h"

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_PIN_CS, TFT_PIN_DC, TFT_PIN_RST);

void setup() 
{
  Serial.begin(9600);
  delay(500);
  Serial.println("Bildschirm: " + String(tft.height()) + " x " + String(tft.width()));
 
  tft.initR(INITR_REDTAB);

  // Bildschirm um 180 Grad drehen
  tft.setRotation(2);

  // schwarzer Hintergrund
  tft.fillScreen(ST7735_BLACK);

  // verschiedene Schriftgrößen
  tft.setTextSize(1);
  tft.setCursor(1, 5);
  tft.setTextColor(ST7735_BLUE);
  tft.print("Text");
  delay(500);

  tft.setTextSize(2);
  tft.setCursor(1, 20);
  tft.setTextColor(ST7735_GREEN);
  tft.print("Text");
  delay(500);

  tft.setTextSize(3);
  tft.setCursor(1, 40);
  tft.setTextColor(ST7735_RED);
  tft.print("Text");
  delay(500);

  tft.setTextSize(4);
  tft.setCursor(1, 70);
  tft.setTextColor(ST7735_YELLOW);
  tft.print("Text");
  delay(2000);

  // Linien ziehen
  tft.fillScreen(ST7735_BLACK);
  tft.drawLine(1, 1, tft.width(), 1, ST7735_ORANGE);
  tft.drawLine(1, 30, tft.width(), 30, ST7735_ORANGE);
  tft.drawLine(1, 60, tft.width(), 60, ST7735_ORANGE);
  delay(2000);

  // Kreise zeichnen
  tft.fillScreen(ST7735_BLACK);
  tft.fillCircle(60, 60, 50, ST7735_MAGENTA);
  tft.fillCircle(60, 60, 30, ST7735_GREEN);
  tft.fillCircle(60, 60, 30, ST7735_YELLOW);
  delay(2000);

  // Rechtecke zeichnen
  tft.fillScreen(ST7735_BLACK);
  tft.drawRect(1, 1, 50, 50, ST7735_ORANGE);
  tft.drawRect(5, 5, 50, 50, ST7735_ORANGE);
  tft.drawRect(10, 10, 50, 50, ST7735_ORANGE);
  delay(2000);

  // ausgefüllte Rechtecke zeichnen
  tft.fillScreen(ST7735_BLACK);
  tft.fillRect(5, 5, 50, 50, ST7735_GREEN);
  tft.fillRect(10, 10, 70, 70, ST7735_BLUE);
  tft.fillRect(15, 15, 90, 90, ST7735_RED);
}

void loop() 
{
  // nichts zu tun, das Programm
  // läuft nur einmal
}

				
			

Funduino - Dein Onlineshop für Mikroelektronik

  • Dauerhaft bis zu 10% Rabatt für Schüler, Studenten und Lehrkräfte
  • Mehr als 3.500 Artikel sofort verfügbar!
  • Über 8 Jahre Erfahrung mit Arduino, 3D-Druck und co.
SALE