0% found this document useful (0 votes)
2 views3 pages

Reporte

The document contains an Arduino code that utilizes ultrasonic distance measurement and servo motor control. It initializes an LCD display and defines functions to control the servo based on distance readings. The code continuously measures distance and triggers different servo positions based on specific distance thresholds.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Reporte

The document contains an Arduino code that utilizes ultrasonic distance measurement and servo motor control. It initializes an LCD display and defines functions to control the servo based on distance readings. The code continuously measures distance and triggers different servo positions based on specific distance thresholds.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Int NOE ;

Int motor = 4;

Int servo;

Int trig = 5;

Int eco = 6;

Int DURACION;

Int DISTANCIA;

Int distancia;

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

#include <Servo.h>

LiquidCrystal_I2C lcd(0x27,16,2);

Servo myservo;

Void setup() {

// put your setup code here, to run once:

Myservo.attach(9);

pinMode(trig, OUTPUT);

pinMode(eco, INPUT);

Serial.begin(9600);

Lcd.init();

Lcd.backlight();

Void ANGEL() {

Myservo.write(180);

Void ALEXA (){

Myservo.write(0);
}

Void loop() {

digitalWrite(trig, LOW);

delayMicroseconds(2);

digitalWrite(trig, HIGH);

delayMicroseconds(10);

digitalWrite(trig, LOW);

DURACION = pulseIn(eco, HIGH);

DISTANCIA = DURACION * 0.034 / 2;

NOE = DISTANCIA;

Serial.print(“noe”);

Serial.print(NOE);

Serial.println(“CM”);

Lcd.setCursor(3,0);

Lcd.print( NOE);

Delay(500);

Lcd.setCursor(2,1);

Lcd.print(“Ywrobot Arduino!”);

Delay (500);

If (NOE == 5 ){

ALEXA ();

Else if (NOE == 10){

ANGEL();
}

You might also like