Arduino & C# – HC SR04 Distance Meter C# App For Arduino

Hello world! Today i made a C# App For Arduino to display The distance with a HC-SR04 Ultrasonic sensor, The code is very simple and you could also use the app for other sensors to display a value by simply sending the value to serial Serial.println(distance); or whatever you name your value, so if you wanna display temperature you can simply display temperature on this app by sending the value from arduino to the serial.

Files you modify in the C# source are the following. Form1.cs & Form.1Designer.cs
To modify the look of the Application you simply double click on Form1.cs and the Form1.cs [Design] should pop up. You can now drag and drop buttons and whatever you want from the toolbox, and change background in the properties etc. If adding a button for example, double click the button to give it a function, Double clicking it will bring you to the part of the code that belongs to the button.

You can also change the about box by double clicking on the about box AboutBox1.cs, You can change background, font, colors etc.
To change company name, version etc. you can double click Properties in the [solution explorer]. And then at [application] click on [assembly information], you can also modify AssemblyInfo.cs directly.

Schematic:

HC-sr04 distance meter
HC-sr04 distance meter

Simply wire it up like the schematic and upload the arduino code. Open the windows application and press the read distance button.

Parts list.

 

  • Arduino uno
  • HC-SR04 Ultrasonic sensor.
  • Jumper wire set MM/FF/MF
  • The Windows application
  • Visual Studio to build your own windows app from the source.(optional)

 

C# Source: Download here

Arduino code:

Good luck!

Follow me on youtube!

facebook-profile-picture
Danny van den Brande

http://www.arduinosensors.nl

<p>I like to code electronics, do 3D Design, Webdesign and Graphic Design.</p>

Leave a Reply

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