Fiverr gig
$15 — I will help you with your project and simulate it for you
Hire me
🤖 Arduino Projects

Interfacing 16x2 LCD with Arduino

The Engineer PostMay 29, 20265 min read
[Interfacing 16x2 LCD with Arduino](https://circuitdigest.com/microcontroller-projects/interfacing-16x2-lcd-with-arduino) — Arduino UNO tutorial cover image

Welcome to this beginner-friendly Arduino tutorial on the sound. By the end of the guide, you'll wire the module to an Arduino UNO, flash a short sketch, and read live values on the Serial Monitor — no prior electronics experience required.

What you'll learn

  • How the module works in plain language
  • The exact parts you need and how to wire them safely
  • The full Arduino IDE sketch with comments
  • Common issues and how to fix them
[Interfacing 16x2 LCD with Arduino](https://circuitdigest.com/microcontroller-projects/interfacing-16x2-lcd-with-arduino) — overview
[Interfacing 16x2 LCD with Arduino](https://circuitdigest.com/microcontroller-projects/interfacing-16x2-lcd-with-arduino) — wiring diagram

Arduino code

Open the Arduino IDE, paste the sketch below into a new file, install any libraries the sketch #includes (Tools → Manage Libraries), select your board and COM port, then click Upload.

/* Arduino pins where the LED is attached*/
#define LED_1 2
#define LED_2 3
#define LED_3 4
#define LED_4 5
#define LED_5 6

#define sensorPin A0 // Analog input pin that the Sensor is attached to

/* boolean variables to hold the status of the pins*/

bool ledPin1Status;
bool ledPin2Status;
bool ledPin3Status;
bool ledPin4Status;
bool ledPin5Status;

void setup() {

  pinMode(LED_1, OUTPUT);
  pinMode(LED_2, OUTPUT);
  pinMode(LED_3, OUTPUT);
  pinMode(LED_4, OUTPUT);
  pinMode(LED_5, OUTPUT);

  pinMode(sensorPin, INPUT);

  Serial.begin(9600);// initialize serial communications at 9600 bps:

}

void loop() {

  int sensorValue = analogRead(sensorPin);
  Serial.println(sensorValue);

  if (sensorValue > 555  )
    ledPin1Status = 1;

   if (sensorValue > 558  )
    ledPin2Status = 1;


   if (sensorValue > 560  )
    ledPin3Status = 1;

   if (sensorValue > 562  )
    ledPin4Status = 1;


   if (sensorValue > 564 )
    ledPin5Status = 1;

  if (ledPin1Status == 1 || ledPin2Status == 1 || ledPin3Status == 1 || ledPin4Status == 1 || ledPin5Status == 1)
  {
    if (sensorValue > 555 || sensorValue < 537  )
      digitalWrite(LED_1, HIGH);

     if (sensorValue > 558 || sensorValue < 534  )
      digitalWrite(LED_2, HIGH);


     if (sensorValue > 560 || sensorValue < 534  )
      digitalWrite(LED_3, HIGH);

     if (sensorValue > 562 || sensorValue < 531 )
      digitalWrite(LED_3, HIGH);


     if (sensorValue > 564 || sensorValue < 528)
      digitalWrite(LED_4, HIGH);

     if (sensorValue > 568 || sensorValue < 525)
      digitalWrite(LED_5, HIGH);

    delay(200);

    ledPin5Status = 0;
    ledPin4Status = 0;
    ledPin3Status = 0;
    ledPin2Status = 0;
    ledPin1Status = 0;

  }
  
  digitalWrite(LED_1, LOW);
  digitalWrite(LED_2, LOW);
  digitalWrite(LED_3, LOW);
  digitalWrite(LED_4, LOW);
  digitalWrite(LED_5, LOW);

}

How it works

The sketch initialises serial communication and the sound driver in setup(), then in loop() it samples the sensor at a regular interval and prints the result to the Serial Monitor at 9600 baud. Open the Serial Monitor (Ctrl+Shift+M) after upload to see live readings.

Troubleshooting checklist

  • No readings: verify the baud rate in Serial Monitor matches the sketch (usually 9600).
  • Garbage characters: wrong baud rate or loose GND wire.
  • Library not found: install the exact library referenced in the #include line via Library Manager.
  • Sensor not detected (I²C): run an I²C scanner sketch to confirm the address.

What to build next

Once the basic readout works, try logging values to an SD card, sending them over Wi-Fi with an ESP32, or pushing them to a Blynk IoT dashboard. Pair this module with our simulator round-up to prototype the circuit before soldering.

Frequently Asked Questions

Q.What library do I need for the sound?

Open Arduino IDE → Tools → Manage Libraries, then search for any library named in the sketch's #include lines and install the latest version.

Q.Why does the Serial Monitor show nothing?

The most common cause is a baud-rate mismatch — set the Serial Monitor to 9600 baud (bottom-right dropdown) so it matches Serial.begin(9600) in the code.

Q.Can I use this with an ESP32 instead of Arduino UNO?

Yes. The sound works with any 3.3-5 V microcontroller. Just remap the wiring to ESP32 I/O pins and keep the rest of the sketch the same.

TEP

The Engineer Post

Embedded systems engineer and educator. Writes weekly tutorials at EmbedLab to help beginners ship real hardware.

Related projects

Browse all 50+ projects