Can someone please tell me what's going on with my LCD screen and how I can fix this issues below?

I have the following:

  • Arduino Uno R3 w/ ATMEGA 328P-PU
  • 16x2 LCD
  • TowerPro MicroServo SG90
  • DPDT Slide Switch w/ 120 ohm resistor

Objective: Read the sensor value (If switch is on or off), and move a servo accordingly while displaying switch state on LCD.

Issue: LCD display seems to receive random data during program run (see image). All starts up well, and as soon as a few seconds have lapsed in the void loop(), the screen becomes garbled. Also, the switch value (while debugging) gets a zero reading while HIGH, acting accordingly as if the switch was off. The servo motor runs as it should, but gets random pulses every now and again where it starts to buzz, but doesn't turn.

Images: Three images below.

Outcome 1 Outcome 2 Garbled Data Received

Schematic: Schema


#include <LiquidCrystal.h>
#include <Servo.h>

const int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor
int oldPos = 0;
int pos = 0;
int oldStat = 0;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Servo servo;

void setup() {
  lcd.begin(16, 2);
  lcd.setCursor (0, 0);
  lcd.print("Starting up FSS!");
  lcd.print("Init SERVO...");
  lcd.print("SERVO Success!");
  lcd.print("Testing SERVO...");
  lcd.print("SERVO Running!");
  lcd.print("Select AUX Source");
  pinMode(ledPin, OUTPUT);

void loop() {
  lcd.setCursor (0, 0);
  lcd.print("Select AUX Src");
  lcd.setCursor(0, 1);

  sensorValue = analogRead(sensorPin);
  Serial.print("Sensor: ");

  if(sensorValue == 0){
    //if(sensorValue = oldStat){
      oldStat = sensorValue;
      digitalWrite(ledPin, LOW);
      lcd.print("Switch is OFF");
      pos = 45;

      Serial.println("Switch is OFF");
  } else{
    digitalWrite(ledPin, HIGH);
    lcd.print("Switch is ON");
    pos = 120;
    Serial.println("Switch is ON");

  if (pos != oldPos){

  oldPos = pos;

  delay (700);

1 Answer 1


Insufficient decoupling. Put a 100nF cap on the supply lines at the LCD and a 100uF cap on the supply lines at the servo.

  • I'll need to get the 100nF and then I'll install that. I'm also going to build a voltage supply apart from the base. If the decoupling works, I'll mark as answer. Thanks! Oct 19, 2014 at 19:05
  • Get a dozen or so. They're one of the most common to use. Oct 19, 2014 at 19:09
  • Electronics is not my strong suit (obviously) so what's happening here? The arduino is behaving correctly (and probably reading the value correct) but it just can't display it because of noise from the servo affecting the transmission to the LCD? So a Serial.println would print the correct value or not?
    – Madivad
    Oct 20, 2014 at 23:58
  • @Madivad: The servo has caused the power to the panel to go pear-shaped, so you can't even know if the electronics in it are in any shape to be sent any commands or data. Oct 21, 2014 at 0:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.