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:

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

   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!
btuğcu2 days ago

hi , visual basic says "no com port 6" can you help me? and i ask one question did you connect usb or serial port cable thankss

AMK933 months ago

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Á15 months 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Á15 months 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.

greatidea6 months ago

Excellent tutorial. I succeeded in properly running this.

bsairam11 months ago

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

for my home purpose

thanx in advance

Fyodor12 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 ?

allc18651 year 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)  allc18651 year ago

What's exactly you mean ?

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

Please try again,


Hi thank you for the links. The first one:

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

The second one, however,

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

Thanks! :)

RuiSantos (author)  allc18651 year ago

Try to download with mozilla or something

That file is hosted by (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,


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,