LCD and ADC connections and code

I am using LC OLED TFT display 1.3 inch which works only with ST7789 library and I have AdaFruit 12 Bit Analog to Digital Converter, ADS1015. Both LCD and ADS are connected to Nano but not to each other. I want to connect them and print my values to my display. Does anyone know how should I connect them and what should I add to this code to send these values to LCD? I am using this code for ADS1015:

#include<Adafruit_ADS1X15.h>
#include<Wire.h>
Adafruit_ADS1015 ads;
void setup (void){
Serial.begin(115200);
if (!ads.begin()) {
Serial.println("Failed to initialize ADS.");
while (1);
}
ads.setGain(GAIN_ONE);
}
void loop (void){
int16_t adc0;
float volts0;
adc0=ads.readADC_SingleEnded(0);
volts0 = ads.computeVolts(adc0);
Serial.print("AIN0: "); Serial.print(adc0); Serial.print(" "); Serial.print(volts0); Serial.println("V");
Serial.println("");
delay(1000);
}

LCD:

Hi, @eceilgaz
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

This will help with advice on how to present your code and problems.

Have you got code for each of the LCD and ADC to prove they work separately?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

1 Like

Yes, ADC code is in my question and LCD code is this:

ST7789 240x240 IPS (without CS pin) connections (only 6 wires required):
#01 GND -> GND
#02 VCC -> VCC (3.3V only!)
#03 SCL -> D13/SCK
#04 SDA -> D11/MOSI
#05 RES -> D8 or any digital
#06 DC -> D7 or any digital
#07 BLK -> NC
*/
#define TFT_DC 7
#define TFT_RST 8
#define SCR_WD 240
#define SCR_HT 240
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Arduino_ST7789_Fast.h>
Arduino_ST7789 lcd = Arduino_ST7789(TFT_DC, TFT_RST);
void setup()
{
lcd.init(SCR_WD, SCR_HT);
lcd.fillScreen(BLACK);
delay(5000);
}
void loop()
{
lcd.drawRect(0,0,240,240,RED);
lcd.setTextColor(WHITE);
lcd.setTextSize(2);
lcd.setCursor(30,80);
lcd.println("HELLO");
lcd.setTextSize(6);
lcd.setCursor(100,130);
lcd.println("??");
lcd.setTextColor(BLACK,WHITE);
delay(10000);
lcd.setTextSize(6);
lcd.setCursor(100,130);
lcd.println("WORLD");
lcd.setTextColor(BLACK,WHITE);
delay(15000);
}

Hi,
Google;

how to combine two arduino codes

A schematic of your project would be good too, a hand drawn image would be fine.
Tom... :smiley: :+1: :coffee: :australia:

1 Like

Hi,
Okay so with both systems working, look at the Google results I suggested in post #4.

With them both running in the one code, you should then be able to put the variable from the ADC into the display variable of the LCD.

Tom.... :smiley: :+1: :coffee: :australia:

Hi,
Thank you so much for your help. Do you know the necessary connections between them too? :grinning: :pray:

You do not connect them together to get the LCD to display the ADC value, you do that in your code.
Your code is reading the ADC and storing a value that you at the moment you send to the IDE serial monitor.
Your other code is displaying variables that are in the code.
When you combine the two, then make the LCD display the ADC value.

But first get the two codes to work in the same code without errors, before trying to display ADC values.

Tom.... :smiley: :+1: :coffee: :australia:

Thank you really much, have a nice day :pray: :grinning:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.