Sunteți pe pagina 1din 9

11/16/2011

Control LED with Arduino And Visual Ba

Home About Links Exchange Contact Inspirasi Latihan Industri Uniten Subscribe MohdHafizul[Dot]Com Hidup Menang Mati Syurga

Control LED with Arduino And Visual Basic


by Joe on January 14, 2011

Single LED Control With Arduino and Visual Basic 6 I just got my Arduino Uno starter kit last Thursday from myduino.com but having problem using the jumper wire since the diameter is smaller compare to the Arduino female pin input. After unboxing, I upload the Hello World example to understand how the Arduino works, pretty simple actually because the language is straightforward and easy to understand. Controlling Arduino with with Visual Basic is actually can be done using Microsoft Comm Control.

mohdhafizul.com/control-led-with-ardui

1/9

11/16/2011

Control LED with Arduino And Visual Ba

MSComm Active X The Interface

Visual basic 6 Interface


mohdhafizul.com/control-led-with-ardui 2/9

11/16/2011

Control LED with Arduino And Visual Ba

There are two method to turn ON/OFF the LED, one is by using SEND button which send data 1 for ON and another string is for OFF. While LED ON and LED OFF is directly send 1 and 0 string. The Code VB6 Code 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ''Simple demo Arduino + Visual Basic 6 Serial Comm ''Still working on advance project ''For tutorial project go to http://mohdhafizul.com/category/arduino
?

Dim ledStatus As String Private Sub Command1_Click() ledStatus = userInput.Text MSComm1.Output = ledStatus End Sub Private Sub Command2_Click() ''on the LED ledStatus = 1 MSComm1.Output = ledStatus End Sub Private Sub Command3_Click() ''of the LED ledStatus = 0 MSComm1.Output = ledStatus End Sub Private Sub Form_Load() MSComm1.RThreshold = 1 MSComm1.InputLen = 1 MSComm1.Settings = "9600,n,8,1" ''baud rate, parity, bit number and stop bit MSComm1.CommPort = 10 '' change according to your port number MSComm1.DTREnable = False MSComm1.PortOpen = True End Sub Private Sub Form_Unload(Cancel As Integer) MSComm1.PortOpen = False End Sub

Important!!. You have to add the Microsoft Comm Control inside the Form. Go to menubar click on Project>Components>Microsoft Comm Control or just CTRL+T

mohdhafizul.com/control-led-with-ardui

3/9

11/16/2011

Control LED with Arduino And Visual Ba

MSComm Active X Arduino Code Just simple on and off LED code using pin no 13 as output 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 //Simple demo Arduino + Visual Basic 6 Serial Comm //Still working on advance project //For tutorial visit http://mohdhafizul.com/category/arduino int userInput=0; int ledPin=13; void setup() { Serial.begin(9600); pinMode(ledPin,OUTPUT); } void loop() { if(Serial.available()){ int userInput=Serial.read(); if(userInput=='1') // 1 to set the LED ON {digitalWrite(ledPin,HIGH);} else {digitalWrite(ledPin,LOW);} } }
?

UPDATE!!!

mohdhafizul.com/control-led-with-ardui

4/9

11/16/2011

Control LED with Arduino And Visual Ba

31/1/2011 I just installed the Visual Basic 2008 Express Version and play with the code. I think it is much easier for me to code in the new version of Microsoft Visual Basic. It seem that there are lot of different using VB6 and VB2008 for example; if i want to create the form1 I must included all code from Form1 inside the Form1 Class and must be closes with End Class, otherwise i will keep getting the error Statement is not valid in a name space . Code for Visual Basic 2008 Just add two button Button 1 for ON and Button 2 for close. The Arduino Code is still the same. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17
?

Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.Eve SerialPort1.PortName = "Com10" SerialPort1.Open() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System. SerialPort1.Write("1") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System. SerialPort1.Write("0") End Sub Private Sub Form1_Disposed(ByVal sender As Object, ByVal e As System.EventA If SerialPort1.IsOpen() Then SerialPort1.Close() End If End Sub End Class

Bug : I need to close my VB program to upload new edited code, since it cannot use the same port simultaneously.

Tags: visual basic arduino,arduino vb6,arduino visual basic 6,vb6 arduino,visual basic 6 arduino,arduino led visual
mohdhafizul.com/control-led-with-ardui 5/9

11/16/2011

Control LED with Arduino And Visual Ba

basic,arduino e visual basic,arduino uno visual basic,vb arduino led,arduino with visual basic,visual basic and arduino,arduino led controller,arduino to visual basic,arduino y visual basic,visual basic 2008 arduino,MSCOMM(activex de VB6),arduino LED,arduino con visual basic,arduino y visual basic 6,VB Y ARDUINO

{ 10 comments read them below or add one }

That_guy_22 February 8, 2011 at 12:48 pm Hey man I just wanna say thanks. I have been searching for weeks on something like this. great job!

Joe February 19, 2011 at 10:57 am Thanks. check my other project here http://mohdhafizul.com/simple-aduino-servo-controller-with-visualbasic/

That_guy_22 April 23, 2011 at 9:08 am Hey man, I have this thing working on my Aduino with VB6. I am now trying to get it going with a Picaxe 08M. Having no luck. Do you have any exp working with these chips? trying to blink an LED. Thanks again!

Joe April 26, 2011 at 9:04 am i have no experience with Picaxe 08M.maybe this article will help http://letsmakerobots.com/node/26434

Thomas Jerome Newton May 10, 2011 at 1:09 pm Excellent article, Code worked for me 1st time! At least once I changed your " to proper quotes. Saved me a lot of brain pain, thanks!

Mark July 20, 2011 at 12:27 pm Hey, I cant declare SerialPort1 in the vb8 express that i just installed. are there any add ins or any steps I missed?, thanks!

joe July 24, 2011 at 1:11 am @Mark changethis part &quot to original . the browser cant show the code correctly
mohdhafizul.com/control-led-with-ardui 6/9

11/16/2011

Control LED with Arduino And Visual Ba

N G Kesari September 13, 2011 at 11:47 am Wonderful blog, very easy to understand even for a dummy like me. Cheers -Kesari Bangalore India

MGD October 12, 2011 at 3:58 pm thank man ,,but not working cant declare serialport1 [ yes the quot] i did it ..i newbie in programing so this is just the code nothing else. thx

Kukiaz October 17, 2011 at 9:19 pm Hey thanks dude.. This is very useful.. Leave a Comment Name * E-mail * Website

Submit

Previous post: Big Move : 2011 Next post: UNITEN Hack@10 Capture The Flag

mohdhafizul.com/control-led-with-ardui

7/9

11/16/2011

Control LED with Arduino And Visual Ba

My Arduino Project
1. Arduino Visual Basic Servo Controller 2. Arduino Visual Basic LED Controller 3. Visual Basic Dual Axis Manipulator

Recent Posts
Kredit Celcom Dicuri | Hilang Lepas Topup? Azz Marketing Masihkah Ada Harapan Keputusan | Malaysia VS Lubnan Wan Zack Haikal Wan Nor Terbaik Cara gosok baju tanpa sterika Malabar SMS Semak Keputusan UPU Melalui SMS Semak Pangilan PLKN Melalui Online dan SMS Semakan saman trafik dan blacklist jpj melalui Online | SMS MyBSN Perbankan Online BSN Gambar Perodua MyVi Baru dan Harga 2011

Recent Comments
ann on Eksperiment Nuffnang vs Advertlets vs Castclick Qassam on Links Exchange joyah on Azz Marketing Masihkah Ada Harapan joyah on Azz Marketing Masihkah Ada Harapan Bro Ka on Azz Marketing Masihkah Ada Harapan Get blogging with a WordPree Themes WordPress Admin
mohdhafizul.com/control-led-with-ardui 8/9

11/16/2011

Control LED with Arduino And Visual Ba

mohdhafizul.com/control-led-with-ardui

9/9

S-ar putea să vă placă și