VisualDuino

Intro: VisualDuino

Welcome fellow maker.

In this project, I am planning on making an easier way to connect Visual Studio and Arduino.

Sending and Receiving data simple enough. But using this data is not and most of the times it gets difficult for people that are just starting.

This instructable will be updated as I process on developing. Summer of 2018 is here and I plan to finish this project by September. By then i want to make an easy to use library for visual studio.

VisualDuino is written on Visual Basic but the code is so simple that anyone can easily convert it to C# if you want.

You can follow the GitHub project here :

GitHub Project.

Step 1: Reading Data.

The first step is to read data from the Arduino. The goal here is to now each pin's value, Digital & Analog.

The Digital Pins will be either HIGH or LOW, aka 1 or 0, aka TRUE or FALSE.

The Analog Pin will be an integer between 0 - 1023

I have decided to represent the digital pins with checkboxes. (Checked is HIGH, unchecked is LOW)

And the Analog Pin's value will be displayed on a textbox.

You can find the Arduino code here(step1.ino file) and the visual studio project on my GitHub page.

  • Upload the code to your Arduino.
  • Start VisualDuino.
  • On the first combobox can select the com port that your Arduino is connected to.
  • On the second combobox you can select the baud rate.
  • Pressing connect will start the data harvesting.

Now you must see the checkboxes and the textboxes values change.

The top long textbox is the latest string that the Arduino has sent.

*Note1 : On the Visual Basic code you can be used the temp list to trigger something if a pin is either HIGH or LOW, or if an analog pin's value is more than.

Example 1.

My goal is when i press a button that is connected to the Arduino I want my pc to play a sound.

First the circuit.

(See picture 1)

I just used a 10K PullDown resistor on Pin 7 of Arduino, so that the pin will be always 0 if the switch is not pressed.

By adding a single line on VisualDuino we can play a sound.

If d7.Checked = True Then My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)

The d7.Checked = True is checking if the pin is HIGH.
This line is recommended to be placed after the d7 check box is updated inside the updateValues sub.

Another way is to make a timer and check the pin each (for example) second.

Example 2.

My goal is to measure a max 5v voltage source.

(*****MORE THAN 5 VOLTS ON AN ANALOG PIN WILL DESTROY THE ARDUINO.*****)

So because the max input voltage is 5V I will not use a voltage divider.

So the only thing I need to is to connect my power source + on my analog pin and the minus(-) on Arduino's GND.

And by changing a single line on the VisualDuino I can measure voltage.

Change :

a0.Text = temp(14)

To :

a0.Text = Math.Round((temp(14) * 5) / 1024, 2) & "V"

As you can see you replace any part of your Arduino code that is calculating some values. I personally used this trick for so many projects when testing or calibrating. Because it is faster and easier to make changes in the code this way.

The VisualDuino code is fully commented. You can change any part and use it on your project.

Next step will be Write values to Arduino.

Step 2: Writing Data

Hello, I made some progress in writing mode on the Arduino and I wanted to share it.

Be aware I am not the best Arduino programmer and probably there is a better way to do it. But I will explain something. I want to make it easier for me later to program the VB app to send and receive data. To change pins modes on the go from INPUT to OUTPUT and vice versa. This will make it later easier and simpler to address easy byte on a specific address.

I made an array of bytes(for now only store the pin's data on it).

byte str[30];

So i can find my pin's HIGH(1) or LOW(0) just by addressing to str[x]

The string will be like :

R025502552550025525525500

It may seem a bit all over the place but :

R-0-255-0-255-255-0-0-255-255-255-0-0

Now it makes for sense R is because the Arduino is 'Reading'

The first 0 is the LOW state of digital pin 2.

The 255 after that is the PWM value of digital pin 3. etc.

So I know that if I want to find the PWM state of (let us say) pin 11 I know that the 3 bytes I need are on exactly the same position each time.

Later the same can be done like this:

R-I0-O255-O0-O255-I0-I0...('-' are just for easier reading here. the real string won't have them.)

R again is Reading.

I0 is Input 0

That will set the pinMode of d2 to input and will ignore the 0 state after that. The serial will just have it there so order will not change.

O255 is Output 255.

But all this are for later. For now, all the pins are set on Output mode and their values get changed from serial.

For more information download the code file. I have tried my best to explain how the code works and what my logic behind it.

Share

    Recommendations

    • Furniture Contest 2018

      Furniture Contest 2018
    • Fix It! Contest

      Fix It! Contest
    • Audio Contest 2018

      Audio Contest 2018

    Discussions