Ultrasonic EZ1

PROJECT 7 – ULTRASONIC RANGE FINDER TO LCD DISPLAY

PROJECT 7

ULTRASONIC RANGE FINDER TO LCD DISPLAY

Back to Project 6                                                                                                         Go to Project 8

Ultrasonic range finder MAXSONAR-EZ1 which can measure the range from 6-inch to 254-inch with also an incredibly small package with ultra low power consumption. It’s provided sonar range information with 1-inch each step. The interface format is include pulse-width, analog and digital output. For this project, we are going to interface this sensor with Arduino and display the output range in inch in LCD display.

———————————————————————————————————————————————————-

COMPONENT NEEDED

———————————————————————————————————————————————————-

MAXBOTIC

MAXSONAR-EZ1

NPN TRANSISTOR 2N2222
  1K RESISTOR x1

4K7 RESISTOR x1

JUMPER WIRE

———————————————————————————————————————————————————-

CONNECTION

———————————————————————————————————————————————————-
Referring to the figure below are the connection of Maxsonar-EZ1 to Arduino. For analog The RED wire are connected to 5V while the Black wire are ground GND. As for the Analog output, connect the ORANGE wire toAnalog port 2(A2) and for the PW output are connected to Digital port 2 which show in GREEN wire.

For UART connection, please refer schematic below.

———————————————————————————————————————————————————-

ADDITIONAL INFORMATION

———————————————————————————————————————————————————-
MAXSONAR-EZ1 Features

· Continuously variable gain for beam control and side lobe suppression.
· Object detection includes zero range objects.
· Single 5V supply with 2mA typical current draw.
· Readings can occur up to every 50mS, (20-Hz rate).
· Free run operation can continually measure and output range information.
· Triggered operation provides the range reading as desired.
· All interfaces are active simultaneously
· Serial, 0 to 5V
· 9600Baud, 81N
· Analog (10mV/inch)
· Pulse width (147uS/inch)
· Learns ringdown pattern when commanded to start ranging.
· Designed for protected indoor environments.
· Sensor operates at 42KHz.
· High output 10V PP square wave sensor drive.

Please check the Maxsonar-EZ1 datasheet for more information.

———————————————————————————————————————————————————-

CODE OVERVIEW

———————————————————————————————————————————————————-

Variables that declare to store the value in long and integer.

adc_key_in = analogRead(analogPin);
Read the ADC input from the keypad.

adc_key_in = get_key(adc_key_in);

Range the ADC keypad value from 1 to 5.

Serial.begin(9600);
Set the Baud rate of serial communication to 9600.

digitalWrite(range_UART_TxPin,HIGH);
HIGH(1) the UART transmit pin.

while(adc_key_in == -1)
Loop forever if the adc_key_in is equal to -1.

anVolt =analogRead(range_analog_analogPin);
Read the ADC output value from Maxsonar EZ1 output pin.

sum += anVolt;
Add all the ADC value together.

inches = sum/avrange
Divided the sum value by 10 to get the average result.

Inches = inches/2;
To get the result in Inches, the average value must be divide by 2 because 1024/522 = ~2.

sum = 0;
Reset the sum value.

range_value_clear();
Clear the LCD value display screen.

pulse =pulseIn(range_pwm_Pin , HIGH);
Detect the input HIGH pulse on the desire pin and range it in milisecond.

inches = pulse/147;
Divide the input pulse by 147 due to each inch of range are range to 147ms.

while(!Serial.available());
Check whether there is data available in serial communication.

Inches = Serial.read();
Read and store the data from serial into inches.

If(inches == ‘R’) data[k=0] = inches;
Check whether the data receive is ‘R’. If yes then store in data[0].

If(data[0] == ‘R’) data[k++] = inches;
If the data[0] is equal to ‘R’. Then the next data are store from data[1] to data[4].

If (k>4) k=4;
Check if K is greater then 4. If yes then reset back to 4.

if (adc_key_in ==1)
Check if the keypad is press UP. If yes then do the following coding.

if (adc_key_in ==2)
Check if the keypad is press DOWN. If yes then do the following coding.

Back to Project 6                                                                                                          Go to Project 8

———————————————————————————————————————————————————-

ATTACHMENT

1. P7 User Manual.pdf
2. Project_7_code.zip

Buy

, , ,

Related Post

Jpeg

How to Make your Line Following Robot Faster?

Control Mobile Robot through WiFi with ESP-WiFi Shield (Arduino + Andriod)

Arduino + 2A motor + Encoder

Arduino + 2A Motor Shield + Encoder Motor

ESPresoo Lite V2 Package

Bringing IoT to Everyone – Collaboration of ASEAN Makers

Leave a Reply

Your email address will not be published. Required fields are marked *