Instructables
Picture of Arduino - Control Servo with Visual Basic
Hi guys,

Today I'll show how you can control a servo with Visual basic. Before this project I’ve never used Visual basic so if anyone finds any mistake in my code please leave a comment here and help me improve it.

you can visit my website for more electronic projects, interesting news and tips:
http://randomnerdtutorials.com/

I've always used the Serial Monitor of the Arduino IDE to communicate with the Arduino, but today we will use a visual basic program that I've created. Basically in the VB program we have 4 buttons that will interact with the Arduino when we press them.

I’ll be showing program in Visual Basic that allows the user to rotate a servo attached to the Arduino. You need to make 3 connections from the servo to your arduino:

   Red: 3.3V (depends on your Servo motor)
   Brown: Ground
   Orange: Digital Pin 9

   Click here to download the VB code
   Click here to download the Arduino Sketch

NOTE:
   When you're using the Visual Basic Program the Serial monitor on the Arduino IDE must be closed
   You need to match the com port on your Visual Basic Code to the right com port you're Arduino is using


I don't know why but youtube cropped my video, the Last two buttons are "Rotate 180º Left" and "Rotate 180º right" . anyway watch it working :)


If you have any questions leave a comment!
Thanks
AMK937 days ago

Hi,
i had tried this with two servos but a problem was found which is the buttons won't work at the same time.
any help please?

CésarÁ11 month ago

Hii!, What Visual Basic Do you used in this proyect?

Because I have a Visual Basic 6 But I can´t see the visual basic code.

CésarÁ11 month ago

Hii!, What Visual Basic Do you used in this proyect?

Because I have a Visual Basic 6 But I can´t see the visual basic code.

greatidea3 months ago

Excellent tutorial. I succeeded in properly running this.

bsairam7 months ago

ur stuff is really nice, can u make the vb code for the following video

for my home purpose

thanx in advance

Fyodor8 months ago

thanks, but I wish this vid was longer. I'd like an explanation of how VB is interacting with the Arduino, the concept is fascinating.

How to connect VB to Arduino ?

allc186510 months ago

Hi, how can I download the source code for this project?

The source code link provided does not allow me to download the file.

Thanks! :)

RuiSantos (author)  allc186510 months ago

What's exactly you mean ?

https://app.box.com/s/2663yu97s9to5i1snw9o

https://gist.github.com/ruisantos16/4773241

I've just tried and both links works fine for me :)

Please try again,

Rui

allc1865 RuiSantos10 months ago

Hi thank you for the links. The first one:

https://app.box.com/s/2663yu97s9to5i1snw9o

downloads as a internet explorer file which does not allow me to download the code.

The second one, however, https://gist.github.com/ruisantos16/4773241

is good enough, but where's the servo.h file?

Thanks! :)

RuiSantos (author)  allc186510 months ago

Try to download with mozilla or something
https://app.box.com/s/2663yu97s9to5i1snw9o

That file is hosted by box.com. (similar to dropbox, and that folder is shared so anyone can download... try with another browser, because everyone downloaded the code successfully.. :) ).

the servo.h file is included in the Arduino IDE (1.0+) by default.

I hope this helps,

Rui

BDS29 RuiSantos10 months ago

Hey guy,

Thank you for all your job, it's really interesting.

However, I don't really understand some step of the program. For example, why do you differenciate if the angle is under 10 or 100?

I would like to use your code in order to create a sinusoidal movement, do you think that's possible?

Thank You,

BDS29