Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Adafruit_GFX.h"
- #include "Adafruit_ILI9341.h"
- #define TFT_DC 9
- #define TFT_CS 10
- #define TFT_RST 8
- #define TFT_MISO 12
- #define TFT_MOSI 11
- #define TFT_CLK 13
- Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
- int analogInput = 0;
- float vout = 0.0;
- float vin = 0.0;
- float R1 = 100300.0; // resistance of R1 (100K) -see text!
- float R2 = 9880.0; // resistance of R2 (10K) - see text!
- int value = 0;
- void setup() {
- Serial.begin(9600);
- tft.begin();
- tft.fillScreen(ILI9341_BLACK);
- tft.drawRect(0, 0, 120, 160 , ILI9341_GREEN);
- tft.drawRect(120, 0, 240, 160 , ILI9341_GREEN);
- tft.drawRect(0, 160, 120, 320 , ILI9341_GREEN);
- tft.drawRect(120, 160, 240, 320 , ILI9341_GREEN);
- pinMode(analogInput, INPUT);
- void setRotation(uint8_t rotation);
- }
- void loop() {
- // read the value at analog input
- value = analogRead(analogInput);
- vout = (value * 4.770) / 1024.0; // see text
- vin = vout / (R2/(R1+R2));
- if (vin<0.09) {
- vin=0.0;//statement to quash undesired reading !
- }
- ////////////////////////// 1° QUADRANTE /////////////////////////////
- tft.setCursor(2,51);
- tft.setTextColor(ILI9341_YELLOW);
- tft.setTextSize(1);
- tft.setRotation(3);
- tft.println("TENSIONE:");
- tft.setCursor(50,45 );
- tft.setTextColor(ILI9341_WHITE);
- tft.setTextSize(2);
- tft.setRotation(3);
- tft.println(vin);
- ////////////////////////// 2° QUADRANTE /////////////////////////////
- tft.setCursor(163,51);
- tft.setTextColor(ILI9341_YELLOW);
- tft.setTextSize(1);
- tft.setRotation(3);
- tft.println("TENSIONE:");
- tft.setCursor(211,45 );
- tft.setTextColor(ILI9341_WHITE);
- tft.setTextSize(2);
- tft.setRotation(3);
- tft.println(vin);
- ////////////////////////// 3° QUADRANTE /////////////////////////////
- tft.setCursor(2,171);
- tft.setTextColor(ILI9341_YELLOW);
- tft.setTextSize(1);
- tft.setRotation(3);
- tft.println("TENSIONE:");
- tft.setCursor(50,165 );
- tft.setTextColor(ILI9341_WHITE);
- tft.setTextSize(2);
- tft.setRotation(3);
- tft.println(vin);
- ////////////////////////// 4° QUADRANTE /////////////////////////////
- tft.setCursor(163,171);
- tft.setTextColor(ILI9341_YELLOW);
- tft.setTextSize(1);
- tft.setRotation(3);
- tft.println("TENSIONE:");
- tft.setCursor(211,165 );
- tft.setTextColor(ILI9341_WHITE);
- tft.setTextSize(2);
- tft.setRotation(3);
- tft.println(vin);
- delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement