LCD not turning on. Voltage problem?

New programmer here. I am trying to make an LCD display analog data from sensors. However, when I run my code, everything but the LCD turns on. Attached is a schematic of the circuit, and my code is below

#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

int blueLed = 10;
int greenLed = 11;
int yellowLed = 12;
int redLed = 13;
int MQ2A3 = A3;
int MQ5A2 = A2;
int MQ7A1 = A1;
int MQ135A0 = A0;//ammonia gas, sulfide, benzene, smoke + toxic gases

//The threshold value
int sensorThres0 = 750;
int sensorThres1 = 800;
int sensorThres2 = 800;
int sensorThres3 = 1000;
//Smoke Threshold is 1000 ← MQ2
//Methane is 800 for flame, higher for gas leaks ← MQ5
//Carbon Monoxide is <200 for good, 200 - 800 is normal, 800-1800 for high, >1800 VERY high ← MQ7, MQ9 measures same thing, but also flammable gases
//Hydrogen 18 - 59% is explosive ← MQ8
//Ammonia, Sulfide and Benze 750 is good, 750-1200 is slightly elevated, 1200 is baddddd  ← MQ135yyyyyyyyy

void setup() {
  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(yellowLed, OUTPUT);
  pinMode(blueLed, OUTPUT);
  pinMode(MQ7A1, INPUT);
  pinMode(MQ5A2, INPUT);
  pinMode(MQ2A3, INPUT);
  pinMode(MQ135A0, INPUT);
void loop() {
  int analogSensor3 = analogRead(MQ2A3);//combustible gas and smoke
  int analogSensor2 = analogRead(MQ5A2);//propane, butane, methane
  int analogSensor1 = analogRead(MQ7A1);//carbon monoxide
  int analogSensor0 = analogRead(MQ135A0);//ammonia gas, sulfide, benzene, smoke + toxic gases
  /*Serial.print("Pin A0: ");
  lcd.print("MQ2: ");//Smoke
  lcd.print("MQ5: ");//H2, LPG, CH4, CO, Alcohol
  lcd.print("MQ7: ");//carbon monoxide
  lcd.print("MQ135: ");////ammonia gas, sulfide, benzene, smoke + toxic gases
  // Checks if it has reached the threshold value
  if (analogSensor0 > sensorThres0)
    digitalWrite(redLed, LOW);
    lcd.setCursor(0, 2);
    digitalWrite(redLed, HIGH);
  if (analogSensor1 > sensorThres1)
    digitalWrite(yellowLed, LOW);
    lcd.setCursor(0, 2);
    digitalWrite(yellowLed, HIGH);
  if (analogSensor2 > sensorThres2)
    digitalWrite(greenLed, LOW);
    lcd.setCursor(0, 2);
  }  else
    digitalWrite(greenLed, HIGH);
  if (analogSensor3 > sensorThres3)
    digitalWrite(blueLed, LOW);
    lcd.setCursor(0, 2);
  }  else
    digitalWrite(blueLed, HIGH);

I even tried printing a random phrase, and it didn't print to the LCD. However, when I connected the LCD only to the Arduino, it worked. I think it might be a problem with the voltage, so I found you can use a transistor to increase voltage, but I don't know how to connect the LCD to the transistor.
Any help would be appreciated!

Your diagram shows pin 3 - "Vo" - connected to 5 V. It should be connected to ground, preferably through a 1k variable resistor to adjust contrast.

A post was split to a new topic: I2c lcd display with Arduino using python pyfirmata

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