# ULTRA SONIC DISTANCE FINDER

65

## Introduction: ULTRA SONIC DISTANCE FINDER

Let's do this
This is a very simple project

### Supplies:

1x arduino
1x lcd display
1x potentiometer
1x HC-05 Ultra sonic sensor
Jumper wires

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Connection

Connect the lcd , hc-05 and arguing as per the scheamatic above.

## Step 2: Coding

#include
#include
int contrast=75;
LiquidCrystal lcd(12,11,5,4,3,2);
#define redPin 9
#define greenPin 10
#define bluePin 8
// Arduino pin numbers
const int SWpin = 6; // digital pin connected to switch output
const int Xpin = 0; // analog pin connected to X output
const int Ypin = 1; // analog pin connected to Y output
int r,b,g,a,n;

void setup() {
pinMode(SWpin, INPUT);
digitalWrite(SWpin, HIGH);
lcd.begin(16,2);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
r=0;
b=127;
g=0;
a=0;
}

void loop() {
{
a=a+1;
};
if(a==4)
{
a=1;
};
switch(a)
{
case 1:
lcd.clear();
lcd.print("Red: ");
if(n==0&r>0)
{
r=r-1;
}
if(n>1000&r<225)
{
r=r+1;
}
lcd.print(r);
setColor(r,g,b);
break;
case 2:
lcd.clear();
lcd.print("Blue: ");
if(n==0&b>127)
{
b=b-1;
}
if(n>1000&b<225)
{
b=b+1;
}
lcd.print(b);
setColor(r,g,b);
break;
case 3:
lcd.clear();
lcd.print("Green:");
if(n==0&g>0)
{
g=g-1;
}
if(n>1000&g<225)
{
g=g+1;
}
lcd.print(g);
setColor(r,g,b);
break;

}
delay(100);

}
void setColor(int red, int green, int blue)
{
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}

https://youtu.be/5f5YZDTalh0

## Recommendations

236
97 20K
33 9.4K
Epilog Laser Class

113 Enrolled