The project in action
What you’ll need
- 1 x ST7735 1.8″ TFT display
- 2 x potentiometers
- 5 x 1k resistors
- 1 x breadboard
- 1 x Arduino Uno R3
- …a bunch of jumper wires
Wiring guide
The code
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
#define TFT_CS 9
#define TFT_DC 10
#define TFT_RST 8
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
float p = 3.1415926;
int controlX = A0;
int controlY= A1;
int valueX = 0;
int outputValueX = 0;
int valueY = 0;
int outputValueY = 0;
void setup() {
tft.initR(INITR_BLACKTAB);
uint16_t time = millis();
tft.fillScreen(ST7735_BLACK);
time = millis() - time;
delay(500);
}
void loop() {
valueX = analogRead(controlX);
outputValueX = map(valueX, 0, 1023, 0, 128);
valueY = analogRead(controlY);
outputValueY = map(valueY, 0, 1023, 0, 160);
tft.drawPixel(outputValueX, (outputValueY-160)*-1, ST7735_WHITE);
}