Dist-Bot

Posted on 15/10/2013 by enigmerald
Modified on: 13/09/2018
Project
Press to mark as completed
Introduction
This is an automatic import from our previous community platform. Some things can look imperfect.

If you are the original author, please access your User Control Panel and update it.

Hello LMRians, After finishing as runner-ups in the line following section of the Yantra 2.0 Robotics Competition, the organizers provided the team  a Roboduino, an Arduino Diecimila Clone. I already had one, and did not want another, as it had taken me a whole day to shake hands between my computer and this board, with a lot of driver and serial port issues. So, i requested them an alternative instead. I had never tried my hands on an LCD, therefore got my self a big-version 20 x 4 LCD.    The ...


Dist-Bot

Hello LMRians,

After finishing as runner-ups in the line following section of the Yantra 2.0 Robotics Competition, the organizers provided the team  a Roboduino, an Arduino Diecimila Clone. I already had one, and did not want another, as it had taken me a whole day to shake hands between my computer and this board, with a lot of driver and serial port issues. So, i requested them an alternative instead.

I had never tried my hands on an LCD, therefore got my self a big-version 20 x 4 LCD. 

 

The Model Number says JHD 204A and has 16 pins on either side (top and bottom) for ease of use.

So, what has this LCD to do with Dist-Bot? As the stupid name suggests, it simply measures the distances using ultrasonic waves emitted by an HC-SR04 sensor, and displays the corresponding results on the LCD.

For Dist-Bot, i used a Spider Controller as it was nearly the same size as the LCD board and it neatly stacked on top of it using appropriate standoffs. Furthermore, the innumerable pins on the Spider made it relatively easier to connect the respective pins.

Next on the list, was the ever popular Ulrasonic Sensors Module, the HS-SR04.

And afer some soldering, some wiring, some screw-driving, this is what Dist-Bot looked like at the end.

At the moment, it's tasks are simply straightforward, the HC-SR04 produces the ultrasonic waves, the distance in centimetres is measured and is displayed on the LCD. If there's an object within a range of 200 cm, it responds along with the distance from the object.

In this case, it spotted the camera while a picture was being taken. It's fine to take a pic, but those HC-SR04s will glare at you!

When it's out of range, it'll respond to that as well, as per the program, in this case it just says, " I see nothing". 

 Upgrades might come along the way, to make use of more devices and do something more than just plain old measurement! For now, that's all about Dist-Bot.

Below is the code I used. To get things working right away, i used the NewPing Library. Feel free to make changes, if you are trying to make something similar. You can also control the TRIG and ECHO outputs of the HCSR04 manually to get the readings.


#include <NewPing.h>

#include <LiquidCrystal.h>



#define TRIGGER_PIN  12  // Arduino pin tied to trigger pin on the ultrasonic sensor.

#define ECHO_PIN     13  // Arduino pin tied to echo pin on the ultrasonic sensor.

#define MAX_DISTANCE 200 // Maximum uS / US_ROUNDTRIP_CM we want to ping for (in centimeters). Maximum sensor uS / US_ROUNDTRIP_CM is rated at 400-500cm.



NewPing sonar(TRIGGER_PIN, ECHO_PIN,MAX_DISTANCE); // NewPing setup of pins and maximum uS / US_ROUNDTRIP_CM.



// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(38, 39, 30, 31, 32, 33, 34, 35, 36, 37); //RS pin, Enable pin, Digital pins



void setup(){

    // set up the LCD's number of columns and rows: 

  lcd.begin(20, 4);

  // initialize the serial communications:

  Serial.begin(9600);

}



void loop()

{

  delay(50);                      // Wait 50ms between pings .

  unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).

  Serial.print("Ping: ");

  Serial.print(uS / US_ROUNDTRIP_CM); // Convert ping time to uS / US_ROUNDTRIP_CM in cm and print result (0 = outside set uS / US_ROUNDTRIP_CM range)

  Serial.println("cm");

     if (uS / US_ROUNDTRIP_CM >= 200 || uS / US_ROUNDTRIP_CM <= 0){ // If there's no object within 200cm or if the distance equals zero

    lcd.clear();

    lcd.setCursor(3,1); // Go to this position. (3,1) implies 3 units towards posiive X-axis and 1 units towards negative Y-axis. We start at (0,0)

    lcd.print("I see nothing!!"); // Notify that no object is spotted within the 200 cm range

  }

  else { // but if there's an object within 200 cm

    lcd.clear();

    lcd.setCursor(2,0); // Go to this position

    lcd.print("Object Spotted!!"); // Notify that there's an object

    lcd.setCursor(2,2);

    lcd.print("It's");

    lcd.setCursor(7,2); 

    lcd.print(uS / US_ROUNDTRIP_CM); // the distance between Dist-Bot and the object

    lcd.setCursor(10,2);

    lcd.print(" Cm");

    lcd.setCursor(14,2);

    lcd.print("far");

  } 

 delay(500); // a delay between the corresponding outputs 

 

}

 

Thanks for reading! Let me know your thoughts.

Ashim

Calculates the distance and reports to an LCD

  • Actuators / output devices: 20X4 LCD
  • Control method: autonomous
  • CPU: Arduino Mega (Spider controller)
  • Power source: 7.2 V LI-ION 1500 mAh battery
  • Programming language: Arduino C
  • Sensors / input devices: Ultrasonic sensors
  • Target environment: Anywhere in range
LikedLike this to see more

Spread the word

Flag this post

Thanks for helping to keep our community civil!


Notify staff privately
It's Spam
This post is an advertisement, or vandalism. It is not useful or relevant to the current topic.

You flagged this as spam. Undo flag.Flag Post