Anda di halaman 1dari 16

let's make

Explore(/tag/typeid/)

Publish(/about/create.jsp)
Login(/account/login/) | SignUp(/account/gopro)

Classes NEW! (/classes/)


Featured: share what you make(/halloween/) (/halloween/)
(/id/intel/) IntelIoT(/id/intel/)
(/)
(/tag/typeid/categorytechnology/channelleds/) LEDs(/tag/typeid/categorytechnology/channelleds/)
(/tag/typeid/categorycostumes/) Costumes(/tag/typeid/categorycostumes/)

AboutThisInstructable

8 129.085 views
94 favorites

License:

techbitar
(/member/techbitar/)
(http://techbitar.com)

Follow
(/member/techbitar/)

705

Bio:DidIunplugthesolderiron?
Morebytechbitar:

(/id/IRRemote

(/file/FVJQARIGSYEPMOF/)

Iknowthishasbeendoneinthepastafewtimessohere'sonemore.Thisisa
skeletalVisualBasic2010andArduinoSketchthatImixedtogethertotestthe
PCtoArduinoUnoconnectionviaserial.ItsimplyturnsLED13onoroff.
TheVisualBasic2010codeassumesyouhaveForm1with2buttonsButton1
andButton2andSerialPort1controls.Button1sendsa1andButton2sendsa0
totheserialportCOM10(changethistomatchyourPCtoArduinoportsetting)

ControlStationforAndroidTURNTHE

TV/)

(/id/SensoDuinoTurnYourAndroid
PhoneintoaWireless/)

(/id/ModifyTheHC

Seeattachedphotoofmysimpleformdesign.
TheArduinoUnoSketchcodesimplywaitsandreadstheserialport.Ifitsee1it
willturnPIN13onandifitsees0itwillturnPIN13off.IfyouhaveanLEDon
PIN13,youcanturnitonandoff.OntheArduinoUno,PIN13isattachedtoa
anonboardLED.
IusedCOM10asaserialportbutyoucan(andmust)changeittomatchyour
Arduinoserialport.
ThepurposeofthiscodeistosimplifyexplanationofhowtoconnectVBto
Arduino.Youcanadderrorprocessingandmoreintelligencebasedonyour
particularneeds.

05BluetoothModuleDefaultsUsingA/)

MakesureyoudragtheSerialPortcontroliconfromtheToolboxonto
yourform.ItshouldhavethenameSerialPort1
WARNING:OnmyPCIhadtoclosetheArduinoIDESerialMonitorwindow
whileruningtheVBprogram,elseIrunintoallsortsoferrormessageabout
COMportaccessdeniedandtheprogramwillfail.
YoucandownloadVisualBasicExpress2010forfreefromMicrosoft
http://www.microsoft.com/visualstudio/enus/products/2010editions/visualbasic
express

'STARTOFVB2010CODE
'NOTE:IamusingCOM10soyouneedtochangetheVisualBasiccodeto
matchyourCOMport
ImportsSystem.IO
ImportsSystem.IO.Ports
ImportsSystem.Threading
PublicClassForm1
Shared_continueAsBoolean
Shared_serialPortAsSerialPort
PrivateSubForm1_Load(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs)HandlesMyBase.Load
SerialPort1.Close()
SerialPort1.PortName="com10"'changecomporttomatchyourArduinoport
SerialPort1.BaudRate=9600
SerialPort1.DataBits=8
SerialPort1.Parity=Parity.None
SerialPort1.StopBits=StopBits.One
SerialPort1.Handshake=Handshake.None
SerialPort1.Encoding=System.Text.Encoding.Default'veryimportant!
EndSub

PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs)HandlesButton1.Click
SerialPort1.Open()
SerialPort1.Write("1")
SerialPort1.Close()
EndSub

PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAs

UsingVisualBasic2010tocontrolArduinoUno
by
System.EventArgs)HandlesButton2.Click
techbitar(/member/techbitar/)intechnology(/tag/typeid/categorytechnology/)
Earduino(/tag/typeid/categorytechnology/channelarduino/)
SerialPort1.Open()

SerialPort1.Write("0")
Download
SerialPort1.Close()
EndSub
EndClass

'ENDOFVB2010CODE

Collection

IMadeit!

Favorite

Share

//STARTOFARDUINOSKETCH
//
//Mixedby:HazimBitar
//Basedon:ScienceGuy14youTubetutorialhttp://youtu.be/g0pSfyXOXj8
intledPin=13//thenumberoftheLEDpin
voidsetup(){
Serial.begin(9600)//setserialspeed
pinMode(ledPin,OUTPUT)//setLEDasoutput
digitalWrite(ledPin,LOW)//turnoffLED
}

voidloop(){
while(Serial.available()==0)//donothingifnothingsent
intval=Serial.read()'0'//deductasciivalueof'0'tofindnumericvalueofsent
number
if(val==1){//testforcommand1thenturnonLED
Serial.println("LEDon")
digitalWrite(ledPin,HIGH)//turnonLED
}
elseif(val==0)//testforcommand0thenturnoffLED
{
Serial.println("LEDOFF")
digitalWrite(ledPin,LOW)//turnoffLED
}
else//ifnotoneofabovecommand,donothing
{
//val=val
}
Serial.println(val)
Serial.flush()//clearserialport
}
//ENDOFARDUINOSKETCH

UsingVisualBasic2010tocontrolArduinoUno by
techbitar(/member/techbitar/)intechnology(/tag/typeid/categorytechnology/)Earduino(/tag/typeid/categorytechnology/channelarduino/)
Wehaveabenicecommentpolicy.
Download
Pleasebepositiveandconstructive.

TanL22(/member/TanL22)

wIMadeit!

AddImages

Collection
PostComment IMadeit!

2monthsago

Reply

Favorite

Share

Hi,ihappenedtofacesystemnullreferenceexceptionerroronthe
serialport1.closeinthepubform1class...
Howdoifixthis?

SallyAnneM1(/member/SallyAnneM1)

3monthsago

Reply

Isitpossibletocommunicatebetweenarduinoandvbwirelessly?

MohamedElAminee(/member/MohamedElAminee)

3monthsago

Reply

thankyouforthisamazingtutorialbutcayouexplainmorehowdoesthe
connectionbetweenthearduinoandtheVBwork?

IsaacPierce(/member/IsaacPierce)

6monthsago

Reply

Thisisreallycool,butcouldsomebodypleasetellmehowIcanrunitwithout
visualstudioafterIcompileit?

Ramog(/member/Ramog) . IsaacPierce(/member/IsaacPierce)

Reply

5monthsago

yeah,the.exefileisinyourprojectfolder.Thereisafolder,
thatisnamedafteryourprojectandinthisfolderthereisabinfolderthis
containsathedebugfolderandinitisyourprojects.exefile

IsaacPierce(/member/IsaacPierce) . Ramog(/member/Ramog)

ThankYou

AfiqI1(/member/AfiqI1)

Reply

5monthsago

8monthsago

Reply

iwouldliketoasanyoneinhere...wheniruntheprograminVisualbasic,error
messageshown"accesstothecomport3isdenied"??didanyoneknowhow
toovercomethisproblem?

(https://cdn.instructables.com/FQH/CCR4/IK5S2WDD/FQHCCR4IK5S2WDD.LARGE.jpg)

11monthsago
UsingVisualBasic2010tocontrolArduinoUno
by
AnezA(/member/AnezA)madeit!

Reply

techbitar(/member/techbitar/)intechnology(/tag/typeid/categorytechnology/)Earduino(/tag/typeid/categorytechnology/channelarduino/)

nice,thanks:)
Download
andhowIcansendastring???

Collection

IMadeit!

Favorite

Share

(https://cdn.instructables.com/F1F/QY2U/IGIDPKX3/F1FQY2UIGIDPKX3.LARGE.jpg)

AfiqI1(/member/AfiqI1) . AnezA(/member/AnezA)

8monthsago

Reply

hi..naktanya..kenapadalamVisualBasicsayakeluarerror"Accesstothe
port'com3'isdenied."?tq

adals1(/member/adals1)

ayearago

Reply

ayearago

Reply

verynice

JoeVu(/member/JoeVu)

Thankyoufortheinfo,,,doyouconsult?digivalve@gmail.com

dhasanshaline(/member/dhasanshaline)

ayearago

Reply

HicanihaveasamplecodesforledONandOFFusingmicrocontroller?

BlanxtarX(/member/BlanxtarX)

ayearago

Reply

Thanksforthetutorialmate.
QHavecreateavb.netUIformyarduinoproject.ineededtochangesome
arduinovariablesthroughtheinterface.howcanidothis?
IEintlite=13
intline=6
intlex=8
voidsetup(){
pinMode(lite,OUTPUT)
pinMode(line,OUTPUT)
pinMode(lex,OUTPUT)}
voidloop(){
digitalWrite(13,HIGH)
delay(1000)
digitalWrite(13,LOW)
delay(1000)
}
sochangeintlite=13tosay7,intlineto9andlexto11throughtheUI...Help
UsingVisualBasic2010tocontrolArduinoUno
by

pleasethanksinadv
techbitar(/member/techbitar/)intechnology(/tag/typeid/categorytechnology/)
Earduino(/tag/typeid/categorytechnology/channelarduino/)
Download
akruti2(/member/akruti2)

Collection
ayearago

IMadeit!
Reply

herebookisavailabletomakesomebasiccoolprojectwitharduino+visual
basic6.0
http://www.amazon.com/ArduinoVisualBasic60software/dp/1511667753
(http://www.amazon.com/ArduinoVisualBasic60software/dp/1511667753)

Favorite

Share

Electrosak(/member/Electrosak)

ayearago

Reply

thanxbrotherforgivingexampleinsimple...helpedmetounderstandfunctions
andmethodology...

NeilV2(/member/NeilV2)

2yearsago

Reply

ihavecodeonvb.netthatwillturnonledonmyarduinobuthowcaniturniton
andoffifiwanttoaddbuttoninmyarduino?
howcaniaddbuttonhereinmycode?

#include<LiquidCrystal.h>
intledPin=13
intbuttonPin=2
//thenumberofthepushbuttonpin
//thenumberoftheLEDpin
intbuttonState=0
//variableswillchange:
LiquidCrystallcd(12,11,5,4,3,2)
voidsetup(){
Serial.begin(9600)//setserialspeed
pinMode(ledPin,OUTPUT)//setLEDasoutput
digitalWrite(ledPin,LOW)//turnoffLED
//
//
lcd.begin(16,2)
lcd.setCursor(0,0)
lcd.print("DaNeiL")
lcd.setCursor(0,1)
lcd.print("GASOLINESTATION")
}

voidloop(){

while(Serial.available()==0)//donothingifnothingsent
intval=Serial.read()'0'//deductasciivalueof'0'tofindnumericvalueof
sentnumber
intbuttonstate=Serial.read()

buttonState=digitalRead(buttonPin)
UsingVisualBasic2010tocontrolArduinoUno
by

if(buttonState==HIGH){
techbitar(/member/techbitar/)intechnology(/tag/typeid/categorytechnology/)
Earduino(/tag/typeid/categorytechnology/channelarduino/)
Download
digitalWrite(ledPin,HIGH)

Collection

Serial.println("PLEASEWAITWHILEREFUELING")
Serial.print('\n')
delay(9000)
digitalWrite(ledPin,LOW)//turntheLEDoffbymakingthevoltageLOW
Serial.println("price40")
Serial.print('\n')
Serial.print('\n')

IMadeit!

Favorite

Share

Serial.println("liters1")
}
else
//turnLEDoff:

if(val==1){//testforcommand1thenturnonLED
Serial.println("P20.001/2")
delay(10)
digitalWrite(ledPin,HIGH)//turnonLED
lcd.clear()
lcd.setCursor(0,0)
lcd.print("PRICE=P20.00")
lcd.setCursor(0,1)
lcd.print("MILLILITERS=500")

{
Serial.println("P40.001")
delay(10)
digitalWrite(ledPin,HIGH)//turnoffLED
lcd.clear()
lcd.setCursor(0,0)
lcd.print("PRICE=P40.00")
lcd.setCursor(0,1)
lcd.print("MILLILITERS=1000")
}
if(val==3){//testforcommand1thenturnonLED
Serial.println("P80.002")
delay(1000)
digitalWrite(ledPin,HIGH)//turnonLED
lcd.clear()
lcd.setCursor(0,0)
lcd.print("PRICE=P80.00")
lcd.setCursor(0,1)
lcd.print("MILLILITERS=2000")
}
elseif(val==4)//testforcommand0thenturnoffLED
{
Serial.println("P120.003")
delay(1000)
digitalWrite(ledPin,HIGH)//turnoffLED
lcd.clear()
lcd.setCursor(0,0)
UsingVisualBasic2010tocontrolArduinoUno
by
lcd.print("PRICE=P120.00")
techbitar(/member/techbitar/)intechnology(/tag/typeid/categorytechnology/)
arduino(/tag/typeid/categorytechnology/channelarduino/)
E
lcd.setCursor(0,1)
Download
IMadeit!
Collection
Favorite
Share
lcd.print("MILLILITERS=3000")
}
if(val==5){//testforcommand1thenturnonLED
Serial.println("P160.004")
delay(10)
digitalWrite(ledPin,HIGH)//turnonLED

lcd.clear()
lcd.setCursor(0,0)
lcd.print("PRICE=P160.00")
lcd.setCursor(0,1)
lcd.print("MILLILITERS=4000")
}
elseif(val==6)//testforcommand0thenturnoffLED
{
Serial.println("P200.005")
delay(10)
digitalWrite(ledPin,HIGH)//turnoffLED
lcd.clear()
lcd.setCursor(0,0)
lcd.print("PRICE=P200.00")
lcd.setCursor(0,1)
lcd.print("MILLILITERS=5000")
}
if(val==8){//testforcommand1thenturnonLED
delay(10)
digitalWrite(ledPin,LOW)//turnonLED
lcd.clear()
lcd.print("DaNeiL")
lcd.setCursor(0,1)
lcd.print("GASOLINESTATION")
}
if(val==9){//testforcommand1thenturnonLED
delay(10)
digitalWrite(ledPin,HIGH)//turnonLED
lcd.clear()
lcd.print("FULLTANK")
lcd.setCursor(0,1)
lcd.print("PLEASEWAIT....")
}

if(val==0){//testforcommand1thenturnonLED
delay(10)
digitalWrite(ledPin,LOW)//turnonLED

}
elseif(val==12)//testforcommand0thenturnoffLED
{
UsingVisualBasic2010tocontrolArduinoUno
by
delay(10)
techbitar(/member/techbitar/)intechnology(/tag/typeid/categorytechnology/)
arduino(/tag/typeid/categorytechnology/channelarduino/)
E
digitalWrite(ledPin,HIGH)//turnoffLED
Download

}
else{

Collection

IMadeit!

Favorite

Share

}
}

talbajjali(/member/talbajjali)

3yearsago

Reply

cansomeonepleaseexplainthiscodeformeireallyfeelstupid:(

intincomingByte=0
intr=9
intg=10
intb=11
intdatar=0
intdatag=0
intdatab=0
intpart=0
intnumbertrans=0
voidsetup(){
Serial.begin(9600)
}
voidloop(){

if(Serial.available()>0){
incomingByte=Serial.read()
if(incomingByte==48){numbertrans=1}
if(incomingByte==49){numbertrans=25}
if(incomingByte==50){numbertrans=51}
if(incomingByte==51){numbertrans=76}
if(incomingByte==52){numbertrans=102}
if(incomingByte==53){numbertrans=127}
if(incomingByte==54){numbertrans=153}
if(incomingByte==55){numbertrans=178}
if(incomingByte==56){numbertrans=204}
if(incomingByte==57){numbertrans=255}
if(incomingByte==44){part++}
if(part==0){datar=numbertrans}
if(part==1){datag=numbertrans}
if(part==2){datab=numbertrans}
if(part==3){
analogWrite(9,datar)
analogWrite(10,datag)
analogWrite(11,datab)
part=0}
//Belowisevildubugstuff
UsingVisualBasic2010tocontrolArduinoUno
by
Serial.println(incomingByte,DEC)
techbitar(/member/techbitar/)intechnology(/tag/typeid/categorytechnology/)
arduino(/tag/typeid/categorytechnology/channelarduino/)
E
}
Download
IMadeit!
Collection
}
Favorite
Share

cfoote7(/member/cfoote7) . talbajjali(/member/talbajjali)

It'stranslatingthecodeintoascii

2yearsago

Reply

felixa1(/member/felixa1)

2yearsago

Reply

Error1'SerialPort1'isnotdeclared.Itmaybeinaccessibleduetoitsprotection
level.C:\Users\Felix\AppData\Local\Temporary
Projects\Arduino1\Form1.vb109Arduino1
howshouldideclareit?

hprosser(/member/hprosser) . felixa1(/member/felixa1)

2yearsago

Reply

2yearsago

Reply

2yearsago

Reply

didyousolvethis??

cfoote7(/member/cfoote7) . hprosser(/member/hprosser)

Addtheserialportobjecttoyourform.

henroljeo.gutierrez(/member/henroljeo.gutierrez)

Hellosir,isitpossible,thatalsothearduinocansenddatainvb.net?canyou
showmethecodes?thanksinadvance)

nuruluyul(/member/nuruluyul)

2yearsago

Reply

hello..ialreadytriedthisanditisawesome..soineedtodothesamethingsbut
usingarduinoandbluetoothhc05..itissameorneedtoaddcomport?dou
haveanyidea?pleasehelpme..tqsir:)

MarinC(/member/MarinC)

2yearsago

Reply

WhenIpressButton2toturnoffLEDwhichisalreadyturnedoffitturnsonfirst
thenitturnsoff.Whyso?

oliviAaaaa(/member/oliviAaaaa)

3yearsago

Reply

ihave6Leds,
Led15useIntegers09foron&offwhichworksfine.
butwheniuse10toturnonLed6thenLed1goeson.iassumethearduino
onlyreadsthefirstinteger.
howcanifixthispleasethanks,,

felixa1(/member/felixa1) . oliviAaaaa(/member/oliviAaaaa) 2yearsago

Reply

**CODE**

UsingVisualBasic2010tocontrolArduinoUno
by
while(Serial.available()>0)

techbitar(/member/techbitar/)intechnology(/tag/typeid/categorytechnology/)Earduino(/tag/typeid/categorytechnology/channelarduino/)

Download

input+=(char)Serial.read()
delay(5)
}
**/CODE**
Thisworksforwordsatleast!

Collection

IMadeit!

Favorite

Share

MartinM4(/member/MartinM4)

2yearsago

Reply

HowIsendvaluesfrommytempsensorwhichisconnectedtoA0ofArduino
Unotovb

eulermath(/member/eulermath)

3yearsago

Reply

hi.
First,Iwanttothanktheprogrammerwhofilledthisgap.Ibuiltonthiscode
snippetandmadearobotcontrolenvironmentthatisprettycool.
I'mnotveryadvancedwithwindowsprogramming.Irememberthatwecanadd
adropdownboxoramenuforchoosingthespecificCOMport.Isthereanyone
herewhohasdonethat?
IjustwanttomakemyprogramlookneatanddecidewhatCOMporttoconnect
toatruntime(arduinoboardschoosedifferentCOM'satdifferentcomputersor
differenttimes).
IsthereawaytomaketheVBprogramdetecttheARDUINOboardCOMport
automaticallysothattheuserdoesnotdoanything(plugandplay)?

muthu_84(/member/muthu_84) . eulermath(/member/eulermath)

Reply

2yearsago

youmayusethebelowcode.AlltheavailableCOMportswillbe
listedinacombobox.ForArduinotobedetectedauto,ialsobeen
searchingforthesolution.

PrivateSubForm1_Load(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs)HandlesMyBase.Load
DimstrPortNames()AsString
strPortNames=SerialPort.GetPortNames
Array.Sort(strPortNames)
ComboBox1.Items.AddRange(strPortNames)
ComboBox1.SelectedIndex=1

sabirpaints(/member/sabirpaints) . muthu_84(/member/muthu_84)

ComboBox1.SelectedIndex=1

Reply

2yearsago

Thiswillautoselectthe2ndItemofyourcombobox.Use0indexfor1st
item.

sabirpaints(/member/sabirpaints)

2yearsago

Reply

Hi,I'mnewoninstructablesandalsoonARDUINO,Canyoupleaseguideme
thatistheSKETCHisnecessaryforanARDUINOSENSOR?Canwenot
directlycontrolourarduinounofromvisualbasic.net?
ActuallyIwanttomeasurewaterlevelinmywatertankusingarduinoultrasonic
sensorandI'mnotfamiliarwiththeprogramminglanguageusedinsketchthat's
UsingVisualBasic2010tocontrolArduinoUno
by
whyIaskedthisstupidquestion.
techbitar(/member/techbitar/)intechnology(/tag/typeid/categorytechnology/)
arduino(/tag/typeid/categorytechnology/channelarduino/)
E
Download
pauljuy(/member/pauljuy)

Collection
2yearsago

IMadeit!
Reply

holaquieriasaberdondepuedoencontrarinformacionpararealisarestetipode
programas

Favorite

Share

X
|
8

ivver(/member/ivver)

2yearsago

Reply

3yearsago

Reply

isthereanywaytodothesamethingbutusingbluetooth?

champ023(/member/champ023)

higuys,I'vegotaproblem.WheneverIuseacommandtoopenserialport,ifI
useboardratefrom19200andaboveVBwillautomaticallysendsomedata(I
don'tknowwhatthisdataisandwhereit'sfrom)tocontrollerviaserialport.But
whenIuseboardrate9600thisproblemdoesn'toccur.

'vbcode
ImportsSystem
ImportsSystem.Threading
ImportsSystem.IO.Ports
ImportsSystem.ComponentModel

PublicClassForm1
PrivateSubForm1_Load(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs)HandlesMyBase.Load
WithSerialPort1

.PortName="Com6"
.RtsEnable=True
.DataBits=8
.BaudRate=19200
.Parity=IO.Ports.Parity.None
.StopBits=StopBits.One
.Open()

EndWith
EndSub
PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs)HandlesButton1.Click

DimintAsInteger=7
SerialPort1.Write(BitConverter.GetBytes(int),0,1)

EndSub
EndClass

UsingVisualBasic2010tocontrolArduinoUno
by
'endofvbcoe
techbitar(/member/techbitar/)intechnology(/tag/typeid/categorytechnology/)Earduino(/tag/typeid/categorytechnology/channelarduino/)

//STARTOFARDUINOSKETCH

Download

voidsetup(){
Serial.begin(19200)
Serial1.begin(19200)
}

Collection

IMadeit!

Favorite

Share

voidloop(){
if(Serial.available()){

intval=Serial.read()
Serial1.print(val)
}

}
//ENDOFARDUINOSKETCH

Thanks.
CHAMP

cpadilla10(/member/cpadilla10)

3yearsago

Reply

Thankyou,thispostisreallyuseful,couldyoutellmepleasewhatchangesare
necessaryinVBcodetocontrol4ledswithkeyboard?,

acalaguin(/member/acalaguin)

4yearsago

Reply

4yearsago

Reply

4yearsago

Reply

Howaboutconnectingtoethernetshieldusingvb2010?

ozzykaka(/member/ozzykaka)

it'scool~
ButitstillnotworkwhenItryitinVB
I"changecomporttomatchyourArduinoport"
AnditworkwhenItestinARDUINO.(Tocheckifit'sok)
IfthereanythingIneedtocheck?

czarlesnomad(/member/czarlesnomad)

Cool!Worksoutjustfine.I'mjustwonderingaboutthiscode:
Shared_continueAsBoolean
UsingVisualBasic2010tocontrolArduinoUno
by
Shared_serialPortAsSerialPort
techbitar(/member/techbitar/)intechnology(/tag/typeid/categorytechnology/)Earduino(/tag/typeid/categorytechnology/channelarduino/)
Ithappenstohaveanerrorandijustcommentedit,Stilltheprogramworks.
Canyouexplainwhy?
Download
IMadeit!
Collection
Favorite
Share

Muiz_9989(/member/Muiz_9989)

4yearsago

HowtoreadandsendserialdatafromapushbuttonattachedtoArduino?

Reply

booliminator(/member/booliminator)

4yearsago

Reply

Hey,thisletsmecontrolpin13,whatifIwanttocontrolmultiplepins???
Pleaseletmeknow,howtocontrolmultiplepins.
Thanks,

X
|
8

techbitar(/member/techbitar)(author) . booliminator(/member/booliminator)
4yearsago

Reply

Youcanaccomplishthisinmanydifferentways.One
wayistosendabytefromthePCtoArduinocontainingapinnumberand
avalue.
Ifwedividethebytewearesendinginto2X4bits,wecanuse4bitsfor
pinnumber0to15andtheother4bitstoalsosendanyvaluefrom0to
15.ThisrequiresbasicbinarymathwhichissupportedbybothArduino
andVB.Ofcourseyoucandecidehowtointerpretthebitpatternsyouare
gettingfromthePC
Example:Supposeyouwanttocontrolpin4toturniton.
1)Wecansetthemostsignificant4bitstonumber4:Inbinarythat's
0100.
2)Thenwesettheleastsignificant4bitsto1111tosignifyON.(use
whateversystemthatworksforyou)
3)Thenwesend01001111fromPCtoArduino
4)AttheArduino,oursketchwillreadeach4bitintopin#+commandand
actaccordingly.
Hopethishelps.

cmcg182(/member/cmcg182)

5yearsago

Reply

Thisisgreatstuff...veryhelpful!!!!Thiscodehelpedmeunderstandthe
concept,however,there'sstillsomethingIdon'tunderstand.Howdoyoucontrol
differentpins?Forinstance,ifIwantedtoadd2morebuttons(button3and4)
andhavethemturnonandoffpin12,alongwiththeothertwobuttonsstill
controllingpin13,howwouldIdothat?Thanks!

X
|
8

techbitar(/member/techbitar)(author) . cmcg182(/member/cmcg182)

Reply

5yearsago

Thanks!youcanapplytheconceptsdiscussedinmyserial
ArduinoguidetosendapinnumberthenactonthatvalueattheArduino
side.Forexampleyoucansendtwobytes,thefirstonecontainsthepin
numberandthesecondonea1or0toturnpinonoroff.Oryoucansend
UsingVisualBasic2010tocontrolArduinoUno
by
aarangeofvaluesthatyoudecidetheirmeaninginsteadofjust1or0.
techbitar(/member/techbitar/)intechnology(/tag/typeid/categorytechnology/)Earduino(/tag/typeid/categorytechnology/channelarduino/)
Download

Collection
booliminator(/member/booliminator) . techbitar(/member/techbitar)

Wherecanwefundyourserialardunioguide?

crob09(/member/crob09) . techbitar(/member/techbitar)

IMadeit!
Reply

4yearsago

Favorite

Share

Thankyou!Iwilltryitwiththeeasydriver.

creativen(/member/creativen)

4yearsago

Reply

4yearsago

Reply

IusevisualBasic2010butitcannotrunwell,itshows:
Error1'SerialPort1'isnotdeclared.Itmaybeinaccessibleduetoitsprotection
level.C:\DocumentsandSettings\Sugianto\LocalSettings\Application
Data\TemporaryProjects\WindowsApplication1\Form1.vb109
WindowsApplication1
Anyoneknowswhathappen?

X
|
8

techbitar(/member/techbitar)(author) . creativen(/member/creativen)

Reply

4yearsago

ChangeCOMportsintheVBcodeandtryitagain.Mycode
usesCOM10butmaybethisportisusedbyotherappsonyourPC.

creativen(/member/creativen) . techbitar(/member/techbitar)

Reply

4yearsago

Finallyigotthecause.ItisnotabouttheCOMthings.
IjustforgottodragSerialPorttothedesignwindow,nowitworkswell.
Thankyouforresponding.
Anyway,inyourcode:

PrivateSubForm1_Load(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs)HandlesMyBase.Load
SerialPort1.Close()
SerialPort1.PortName="com10"'changecomporttomatchyourArduino
port
SerialPort1.BaudRate=9600
SerialPort1.DataBits=8
SerialPort1.Parity=Parity.None
SerialPort1.StopBits=StopBits.One
SerialPort1.Handshake=Handshake.None
SerialPort1.Encoding=System.Text.Encoding.Default'veryimportant!
EndSub

whydoyoustartwithSerialPort1.Close()?

yhlee92(/member/yhlee92) . creativen(/member/creativen) 4yearsago

Reply

Ihavethesameproblemwithyou.WhatyoumeanbydragSerialPortto
UsingVisualBasic2010tocontrolArduinoUno
by
thedesignwindow?ican'tgetit!!

techbitar(/member/techbitar/)intechnology(/tag/typeid/categorytechnology/)Earduino(/tag/typeid/categorytechnology/channelarduino/)
Download

X
|
8

Collection
techbitar(/member/techbitar)(author) . yhlee92(/member/yhlee92)

IMadeit!
Reply

4yearsago

There'saControliconinyourVBtoolsnamedserialport.it'sa
controllikeabuttonorfield.Youdragitontoyourformsoyoucanaccess
itsproperties.

Favorite

Share

I MoreComments

FEATURED CHANNELS

Woodworking
(/tag/type

Paper
(/tag/type

KitchenHacks
(/tag/type

Puzzles
(/tag/type

Space
(/tag/type

id/category
id/category
id/keyword
id/category
workshop/channelcraft/channel kitchen%20hacks/?play/channel
woodworking/)

paper/)

Newsletter

sort=FAVORITES)

puzzles/)

id/keyword
astronomy/?

IceCream
(/tag/type

Homesteading
(/tag/type

3DPrinting
(/tag/type

Sewing
(/tag/type

id/keyword
id/category
id/category
id/category
ice%20cream/? home/channel technology/channel
craft/channel

sort=FAVORITES)sort=FAVORITES)homesteading/)

3DPrinting/)

sewing/)

Join2million+toreceiveinstant
DIYinspirationinyourinbox.
enteremail

I'min!

Mobile
Downloadourapps!
Android(https://play.google.com/store/apps/details?id=com.adsk.instructables)
iOS(https://itunes.apple.com/app/instructables/id586765571)
Windows(http://apps.microsoft.com/windows/enus/app/7afc8194c771441a959054250d6a8300)

AboutUs

FindUs

WhoWeAre(/about/)

Facebook(http://www.facebook.com/instructables)

Advertise(/advertise/)

Youtube(http://www.youtube.com/user/instructablestv)

Contact(/about/contact.jsp)

Twitter(http://www.twitter.com/instructables)

Jobs(/community/PositionsavailableatInstructables/)
Help(/id/howtowriteagreatinstructable/)

Pinterest(http://www.pinterest.com/instructables)
Google+(https://plus.google.com/+instructables)

Resources
ForTeachers(/teachers/)
ArtistsinResidence(/air)
GiftPremiumAccount(/account/give?sourcea=footer)
Forums(/community/)
Answers(/tag/typequestion/?sort=RECENT)
Sitemap(/sitemap/)

TermsofService(http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21959721) |
PrivacyStatement(http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21292079) |
LegalNotices&Trademarks(http://usa.autodesk.com/legalnoticestrademarks/) | MobileSite(http://www.instructables.com)
(http://usa.autodesk.com/adsk/servlet/pc/index?id=20781545&siteID=123112)
2016Autodesk,Inc.

UsingVisualBasic2010tocontrolArduinoUno by
techbitar(/member/techbitar/)intechnology(/tag/typeid/categorytechnology/)Earduino(/tag/typeid/categorytechnology/channelarduino/)
Download

Collection

IMadeit!

Favorite

Share

Anda mungkin juga menyukai