Added new script
This commit is contained in:
53
arduino/Screen code/screen-with-questions-nostyling.ino
Normal file
53
arduino/Screen code/screen-with-questions-nostyling.ino
Normal file
@@ -0,0 +1,53 @@
|
||||
//styling still needs to be done.
|
||||
//this code is to display the questions on the screen.
|
||||
#include <SPI.h>
|
||||
#include "Adafruit_GFX.h"
|
||||
#include "Adafruit_ST7796S_kbv.h"
|
||||
|
||||
#define TFT_CS 14
|
||||
#define TFT_DC 13
|
||||
#define TFT_RST 12
|
||||
#define MOSI 11
|
||||
#define SCK 10
|
||||
#define MISO 9
|
||||
|
||||
char* Question[] = {
|
||||
"How clean are the toilets? (clean, normal, disgusting).",
|
||||
"How clean is the study area? (clean, normal, disgusting).",
|
||||
"What do you think of the temperature in the study area? (hot, perfect, cold).",
|
||||
"How crowded would you say the study area is?(not at all, its fine, really crowded).",
|
||||
"Is there enough help available? (no, decently, yes)"
|
||||
};
|
||||
|
||||
//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 to horizontal
|
||||
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
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
tft.setTextSize(2); // 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
|
||||
tft.setCursor(0, 0); // Set the cursor to the top left corner
|
||||
tft.println(Question[1]);
|
||||
delay(10000); //delay set a longer delay so the long text can write out
|
||||
}
|
Reference in New Issue
Block a user