Adventures with Arduino Part 7

 

LCD RANGE FINDER

As I am not at the after school club today.  I decided to do some more Arduino hacking from the Arduino project handbook I have.

Following on from part 5 of this series.  I moved on to project 32 which is building an ultrasonic range finder.  This is using the HC-SR04 ultrasonic module.

This worked first time,  I decided to modify the code slightly.   The section I modified is below

// convert the time into a distance
  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("dist to object:");
  lcd.setCursor(0, 1);
  lcd.print(inches);
  lcd.print("in, ");
  lcd.print(cm);
  lcd.print("cm");

All this really does is to move the result to line 2 of the LCD and display dist to object on the top line,   where dist is clearly short for distance.

I think this looks nicer.  It does highlight the flexibility of coding in that you can add you own touches to projects.