How to combine a grove lcd-display with Ultra sonic ranger

I want to display my measured distance to an object on my lcd rgb backlight display.
I tried the following, but it gives an error message:

Arduino: 1.8.2 (Windows 10), Board:“Arduino/Genuino Uno”

Display:22: error: expected constructor, destructor, or type conversion before ‘FILE’



exit status 1
expected constructor, destructor, or type conversion before ‘FILE’

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

ultrasonic-range-meter.txt (590 Bytes)

The attached code:

#include <Wire.h>
#include "rgb_lcd.h"
#include "Ultrasonic.h"
rgb_lcd lcd;
Ultrasonic ultrasonic(7);

void setup() {
    lcd.begin(16, 2);

void loop() {
    long RangeInCentimeters;
    RangeInCentimeters = ultrasonic.MeasureInCentimeters();

What’s that business at the end? If you want that to be a comment you’re missing a ‘/’ at the beginning of it.

I am not sure WHY you want to do this:


but it would work better like this:


Notice the added (forward) slash character.

In the future, please follow these instructions for posting…

To post code and/or error messages:

  1. Use CTRL-T in the Arduino IDE to autoformat your complete code.
  2. Paste the complete autoformatted code between code tags (the </> button)
    so that we can easily see and deal with your code.
  3. Paste the complete error message between code tags (the </> button)
    so that we can easily see and deal with your messages.
  4. If you already posted without code tags, you may add the code tags by
    editing your post. Do not change your existing posts in any other way.
    You may make additional posts as needed.
  5. Please provide links to any libraries that are used
    (look for statements in your code that look like #include ). Many libraries
    are named the same but have different contents.

Before posting again, you should read the three locked topics at the top of the Programming Questions forum, and any links to which these posts point.

If your project involves wiring, please provide a schematic and/or a wiring diagram and/or a clear photograph of the wiring.

Good Luck!