Introduction: Arduino & C# - HC SR04 Distance Meter C# App for Arduino

About: Hello world! I make simple & Advanced projects for people who want to learn programming and electronics. Most of my Instructables are about arduino and the wide range of sensors you can use with it. I make…

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.

Step 1: Schematic, Parts List, Code and C# Source + Application

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)

Good luck!

Follow me for more!

Check our website!

Follow me on youtube!

Source on GitHub