0% found this document useful (0 votes)
5 views2 pages

Contador Ultrasonico

This document contains an Arduino sketch that utilizes a LiquidCrystal_I2C library to control an LCD display, along with a buzzer and LED for alerting based on distance measurements. It measures distance using an ultrasonic sensor and increments a counter when an object is detected within a certain range. The counter value is displayed on the LCD, and the program resets the counter after reaching a specified limit.

Uploaded by

businessangel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Contador Ultrasonico

This document contains an Arduino sketch that utilizes a LiquidCrystal_I2C library to control an LCD display, along with a buzzer and LED for alerting based on distance measurements. It measures distance using an ultrasonic sensor and increments a counter when an object is detected within a certain range. The counter value is displayed on the LCD, and the program resets the counter after reaching a specified limit.

Uploaded by

businessangel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <LiquidCrystal_I2C.

h>
#include<Wire.h>
LiquidCrystal_I2C lcd(0x27,16,2);
int led=8;
int Buzzer=7;
int trigger=3;
int echo=2;
int tiempo=0;
int distancia=0;
int contador=0;
void setup() {
Wire.begin();
lcd.begin(16,2);
lcd.backlight();
lcd.clear();
Serial.begin(9600);
pinMode(led,OUTPUT);
pinMode(Buzzer,OUTPUT);
pinMode(trigger,OUTPUT);
pinMode(echo,INPUT);
}

void loop() {
digitalWrite(trigger,LOW);
delay(2);
digitalWrite(trigger,HIGH);
delay(10);
digitalWrite(trigger,LOW);
tiempo=pulseIn(echo,HIGH);
distancia=(tiempo/2)/29;
// Serial.println(distancia);
if(distancia<9){
digitalWrite(led,HIGH);
digitalWrite(Buzzer,HIGH);
delay(100);
digitalWrite(Buzzer,LOW);
}else{
digitalWrite(led,LOW);
contador=contador;
digitalWrite(Buzzer,LOW);
}
if(digitalRead(led)==HIGH)
{
contador++;
delay(400);

}
if(contador>1000){
contador=0;
lcd.clear();
}
Serial.println(contador);
Serial.print(" ");
Serial.print(distancia);
Serial.print(" cm ");
lcd.setCursor(0,0);
lcd.print("Contar Personas");
lcd.setCursor(0,1);
lcd.print("monedas: ");
lcd.print(contador);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy