/* Plotter mit TFT ILI9341
Modifikation von https://wokwi.com/arduino/projects/307567963154678338
*/
#include <Adafruit_ILI9341.h>
#define TFT_CS 9
#define TFT_DC 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
#define WIDTH 320
#define HEIGHT 240
void messung_1() {
analogWrite(5,225);
delay(100);
unsigned int startzeit = millis();
for (int x = 0; x < WIDTH; x++) {
//int mw = analogRead(5)/10;
int mw = digitalRead(4)*40;
tft.drawPixel( mw+20, x, ILI9341_YELLOW);
//Serial.println(mw);
}
unsigned int endezeit = millis();
Serial.println("Messdauer: " + String(endezeit-startzeit) + " ms");
}
int mw[WIDTH];
void messung_2() {
analogWrite(5,128);
delay(100);
unsigned int startzeit = millis();
for (int x = 0; x < WIDTH; x++) {
//int mw = analogRead(5)/10;
mw[x] = digitalRead(4)*40;
}
unsigned int endezeit = millis();
Serial.println("Messdauer: " + String(endezeit-startzeit) + " ms");
for (int x = 0; x < WIDTH; x++) {
tft.drawPixel( mw[x]+20, x, ILI9341_YELLOW);
}
}
void setup(void) {
pinMode(4, INPUT);
tft.begin(); Serial.begin(115200);
tft.setRotation(4);
tft.fillScreen(ILI9341_BLACK);
//tft.drawLine( 0, 0, HEIGHT, WIDTH, ILI9341_RED);
tft.drawLine( 0, 0, HEIGHT, 0, ILI9341_YELLOW);
tft.drawLine( 0, 0, 0, WIDTH, ILI9341_YELLOW);
//messung_1();
messung_2();
}
void loop() {
}