Added screen scripts
This commit is contained in:
40
arduino/Screen code/Screen-example-simplified.ino
Normal file
40
arduino/Screen code/Screen-example-simplified.ino
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <SPI.h>
|
||||
#include "Adafruit_GFX.h"
|
||||
#include "Adafruit_ST7796S_kbv.h"
|
||||
|
||||
#define TFT_CS 14
|
||||
#define TFT_DC 13
|
||||
#define TFT_RST 12 // RST can be set to -1 if you tie it to Arduino's reset
|
||||
#define MOSI 11
|
||||
#define SCK 10
|
||||
#define MISO 9
|
||||
|
||||
//simplify the name of the library
|
||||
|
||||
Adafruit_ST7796S_kbv tft = Adafruit_ST7796S_kbv(TFT_CS, TFT_DC, MOSI, SCK, TFT_RST, MISO);
|
||||
|
||||
|
||||
|
||||
void setup() {
|
||||
tft.begin(); // Initialize the display
|
||||
tft.setRotation(3); // Set the rotation
|
||||
tft.fillScreen(ST7796S_BLACK); // Fill the screen with black color
|
||||
tft.setTextColor(ST7796S_WHITE); // Set the text color to white
|
||||
tft.setTextSize(2); // Set the text size to 2
|
||||
}
|
||||
|
||||
void loop() {
|
||||
tft.setTextSize(5); // Set textsize
|
||||
tft.setCursor(0, 0); // Set the cursor to the top left corner
|
||||
//the cursor is where it types the text or shape on the screen, 0,0 is the topleft
|
||||
tft.println("Hello, world!"); // Print the text
|
||||
delay(2000); // Wait for 2 seconds
|
||||
|
||||
tft.fillScreen(ST7796S_BLACK); // Clear the screen
|
||||
|
||||
tft.setCursor(0, 0); // Set the cursor to the top left corner
|
||||
tft.println("New text!"); // Print the new text
|
||||
delay(2000); // Wait for 2 seconds
|
||||
tft.fillScreen(ST7796S_BLACK); // Clear the screen
|
||||
|
||||
}
|
Reference in New Issue
Block a user