LCD blinks when activating an ultrasonic sensor with servo motor

Hi, I am a beginner in arduino. I am doing a project which serves to dispense alcohol and measure body temperature. To dispense the alcohol I use an ultrasonic sensor which activates a servomotor that makes the alcohol fall. And for the temperature I use an mlx90614 sensor and the result is seen on an LCD display.

The problem is that when you put your hand on the ultrasonic sensor, the servomotor is activated, but at the same time for some reason, the 16x2 display blinks once, when the display is not linked to it.

I tried to see the connections, but I can't solve it, and in the code, the ultrasonic sensor, the servo and the screen are not linked.

What is the problem?

Me too.

Hi @facuaaa
Topic duplicity?

RV mineirin

We need to see your code?
We need to see a circuit diagram?
Include your power supplies.

Can you please post some images of your project so we can see your component layout?

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

How is the servo powered? Not by the Arduino, I hope.

Yes, how do I have to do it?

unsigned long previousMicrosTriac1 = 0;
unsigned long previousMicrosTriac2 = 0;
const long intervalTriac1 = 5000;
const long intervalTriac2 = 5;
#include <LiquidCrystal.h>
#include <Wire.h>
#include <Servo.h>
#include <Adafruit_MLX90614.h>
int BUZZER = 9;
int cm=0;
long distancia,duracion; //long valores decimales 
int posicion1=120;
int posicion2=180;
Servo miServo; //al pin 13
#define Pecho 6 //Echo al pin 6
#define Ptrig 7 //Trig pin 7
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Instanciar objeto
Adafruit_MLX90614 termometroIR = Adafruit_MLX90614();
void setup() {
  pinMode(BUZZER, OUTPUT);
  pinMode(Pecho, INPUT);  //define el pin 6 como entrada (echo)
  pinMode(Ptrig, OUTPUT); //define el pin 7 como salida (triger)
  miServo.attach (10);         //define el pin 13 como salida para mover el servo enviando la señal de distancia menor a 10
  // Iniciar comunicación serie
  lcd.begin(16, 2);
  // Iniciar termómetro infrarrojo con Arduino
void loop() {
  unsigned currentMicros = micros();
  if(currentMicros - previousMicrosTriac1 >= intervalTriac1){
    previousMicrosTriac1 = currentMicros;
      digitalWrite (Ptrig,LOW);
      digitalWrite(Ptrig,HIGH); //genera el pulso de triger de 10ms 
      duracion= pulseIn(Pecho, HIGH);  //con esto sabemos cuanto tiempo estuvo en alto(HIGH)
      distancia =(duracion/2)/29;     //   calcula la distancia en centimetros
      if (distancia <=10 && distancia >=1){
      miServo.write(posicion1);                //mueve el servo si la distancia es menor a 10cm 
      Serial.println("Obstaculo");          //envia la palabra "obstaculo" por el puerto serial 
  if(currentMicros - previousMicrosTriac2 >= intervalTriac2){
    previousMicrosTriac2 = currentMicros; 
    // Obtener temperaturas grados Celsius
    float temperaturaObjeto = termometroIR.readObjectTempC(); 
    lcd.print("Tomese la");
    if (temperaturaObjeto>30){
      lcd.print("Temperatura: ");

everything is powered by the arduino and the cable to the pc. then I send you the photo

With an external supply capable of supplying the current required by the servo. A 4 AA cell pack is a popular power supply for servos. Connect the ground of the pack to Arduino ground as well as the servo. The plus side of the pack goes to the plus supply of the servo, only.

Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.