Members
I am playing around with graph values and are not sure where these connections are made between the Arduino & the pot as there is no schematic. The pics are blurry. It looks like 5V,GND and SCL are used?
//https://www.instructables.com/id/How-to-Create-a-Simple-Oscilloscope-With-Arduino-a/
/* Yellow fillRect moving as the value increase & decrease
*
* and a tft value printed before :ADC
*/
#include <MCUFRIEND_kbv.h>
#include <TouchScreen.h>
MCUFRIEND_kbv tft;
//#include <Adafruit_GFX.h> // Core graphics library
//#include "SWTFT.h" // Hardware-specific library
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
//Touchscreen X+ X- Y+ Y- pins
#define YP A5
#define XM A4
#define YM 10
#define XP 11
//tested as correct for new ADAFRUIT screen
#define TS_MINX 150
#define TS_MINY 90
#define TS_MAXX 900
#define TS_MAXY 800
// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define GREEN 0x07E0
#define WHITE 0xFFFF
#define BLUE 0x001F
#define RED 0xF800
#define YELLOW 0xFFE0
#define CYAN 0x07FF
//SWTFT tft;
void setup(void) {
tft.reset();
uint16_t identifier = tft.readID();
tft.begin(identifier);
tft.setRotation(1);
tft.fillScreen(BLACK);
tft.fillRect(0, 0,320 , 240, BLACK);
tft.drawRect(1, 0, 319, 240, WHITE);
tft.drawRect(9, 9, 202, 40, WHITE);
tft.drawLine(10,90, 10, 240, BLUE);
tft.drawLine(0, 230, 320, 230, RED);//line at bottom of screen
tft.setTextColor(GREEN);
tft.setTextSize(4);
tft.setCursor(215, 15);tft.println("%100");//indicates a bar graph value
tft.setCursor(100, 55);tft.println(" :ADC");
}
void loop(void) {
int j,i;
j=analogRead(A6);//was A5
i=map(j,0,1023,1,200);
tft.fillRect(10, 10,i, 38, YELLOW);//bar graph value
tft.fillRect(i+9, 10, (200-i+1), 38, BLACK);
tft.fillRect(10, 50, 100, 40, BLACK);
tft.setCursor(10, 55);
tft.println(j);
print_x(map(j,0,1023,227,90));
delay(1000);//sample write delay. change this later and use millis
}
int x=12;
void print_x(int h){
tft.drawLine(x, h, x, h+2, CYAN);//draws the actual graph
if(x<300)x++;
else{ x=12;tft.fillRect(11, 90, 300, 140, BLACK);}
}
Thanks in advance