You are on page 1of 6

11/3/2016 Arduino & Visual Basic 6 Light Controller -Use Arduino for Projects

Ard u i n o P ro j ect L i st Ard u i n o P ro j ect s Hu ge L i st o f t u t o ri al s & Co mp o n en t s b ased reso u rces & i n f o P ri v acy P o l i cy Ard u i n o Bo ard Sel ect o r

Search here ...

HOME ARDUIN O PROJECTS TOOLS E- BOOK S TUTORIALS BLOG N EWS & UPDATES SITEMAP CON TACT US

WinHeist – An Electronic Components Organizer for Every Hobbyist » How to Build an Ohmmeter Using an Arduino » ControLeo2 Reflow Oven » The Personal Computer: Fa

You Are Here: Home » Projects » Other Projects » Arduino & Visual Basic 6 Light Controller
Search here ... SEARCH

Arduino & Visual Basic 6 Light Controller

Posted by: ad mi n Posted date: Ap ri l 25, 2013 In: O t h er P ro j ect s, P ro j ect s | comment : 0

Tags: ard u i n o , co n t ro l l er, l i gh t , v i su al b asi c

This instructable is something like a


tutorial for new VB users. It shows
how to create a parser base VB6
program to interact with Arduino
circuit. Basically, interaction is in the
form of serial communication via the
Glass LED
USB port. This is my practice after Tube Lights
learning VB6 for 2 weeks and
hopefully this post can help other
newbies in VB6 to see additional Wholesale Various High
options of interfacing this program. Quality LED Tube from
China LED Tube factory.
Step 1: Arduino
First of all, the process of coding should start from the lowest level programming
platform and in this case, is the Arduino UNO.
We must make sure that the Arduino should be able to perform the task of lighting up
the LEDs connected. I limited the outputs to six pins because i wanted use the PWM
function. The schematic shown above is made from Fritzing Software (Autoroute Option www.eneltec-led.com/
Available)

Popular Recent Comments Tags

Sound Localization using


Arduino
May 09, 2013

Power Quality Meter using


Arduino
November 15, 2014

Wii Nunchuk Controlled Model


Train using Arduino
October 21, 2014

Pachube Client using Strings with Arduino

http://duino4projects.com/arduino-visual-basic-6-light-controller/ 1/6
11/3/2016 Arduino & Visual Basic 6 Light Controller -Use Arduino for Projects

June 18, 2015

Ads by Google ► Arduino GPS ► Arduino Uno ► Arduino Can ► Arduino R3

I would like to compliment pwillard as i used some of this parse codes


Make A Digital Clock From
fromhttp://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1293046321 on his “Live For
Scratch using arduino
Speed” Racing Simulator. His string manipulation tactic is amazing and just what i
April 11, 2013
needed. I have attached my Arduino Code and feel free to ask if there are any
complications. I am also a new learner and just wanted to share what i have achieved so
far with Arduino. Arduino Projects by Application

Arduino Battery Projects


Light.rar 2 KB

Calculator Projects
VBLight.rar 427 KB
Arduino Video – Camera – Imaging
Step 2: Visual Basic 6.0 (Part 1) Projects

Arduino Car Projects


The second step would be starting to code the VB program. I code some functions as
class as this would enable me to create dll. The first class would read text files and store Clock – Timer Projects
them into an array inside the program. I found the code in “Programming Visual Basic
6.0” manual. This function allows me to load pre-programmed commands into the CNC Machines Projects
program to run.
Development Board – Kits Projects

Program Code How To – DIY – Projects

Public Function FileToArray(ByVal filename As String) As String Game – Entertainment Projects


On Error GoTo Error
GPS Based Projects
Dim items() As String, i As Integer
‘ Read the file’s contents, and split it into an array of strings.(Exit here if any error Home Automation Projects
occurs.)
Interfacing(USB – RS232 – I2c -ISP)
items() = Strings.Split(ReadTextFileContents(filename), vbCrLf)
Projects

For i = LBound(items()) To UBound(items()) Internet – Ethernet – LAN Projects


FileToArray = FileToArray & vbCrLf & items(i)
Next Arduino LCD Projects

MsgBox “Commands successfully loaded!” Arduino LED Projects

Exit Function Medical – Health based Projects

Error:
Memory – Storage Projects
MsgBox “Error in FileToArray: ” & Err.Description
End Function
Metering – Instrument Projects

‘read entire context in a file


Arduino Motor Projects
Public Function ReadTextFileContents(filename As String) As String

Other Projects
Dim fnum As Integer, isOpen As Boolean
On Error GoTo Error_Handler ‘ Get the next free file number.
Phone Projects
fnum = FreeFile()
Open filename For Input As #fnum ‘ If execution flow got here, the file has been open Arduino PWM Projects
without error.
isOpen = True ‘ Read the entire contents in one single operation. Radio Projects

ReadTextFileContents = Input(LOF(fnum), fnum) ‘ Intentionally flow into the error


Arduino RFID Projects
handler to close the file.

Robotics – Automation Projects


Error_Handler: ‘ Raise the error (if any), but first close the file.
If isOpen Then Close #fnum

http://duino4projects.com/arduino-visual-basic-6-light-controller/ 2/6
11/3/2016 Arduino & Visual Basic 6 Light Controller -Use Arduino for Projects

If Err Then Err.Raise Err.Number, , Err.Description Arduino RTOS – OS Projects

End Function
Security – Safety Projects

After that, i found the program to load inbox messages from Gmail Sensor – Transducer – Detector
(http://www.j4mie.org/2008/02/15/how-to-make-a-physical-gmail-notifier/ ). I applied Projects
this function to enable loading commands from your Gmail inbox to run the Light
Sound – Audio Projects
Controller.

Temperature Measurement Projects


Program Code

Option Explicit
Private m_TheFile As String, m_TheSection As Variant Ads by Google

Private Username As String, Password As String, iTemp() As String ► Visual Basic 6.0
Private pForm As Form, pTimer As Timer, ptxtBox As TextBox, pInet As Inet ► Arduino Controller
► Arduino Mega 2560
Private Declare Function GetPrivateProfileString Lib “kernel32” Alias
“GetPrivateProfileStringA” (ByVal lpApplicationName As String, ByVal lpKeyName As Any,
ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal
lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib “kernel32” Alias
“WritePrivateProfileStringA” (ByVal lpApplicationName As String, ByVal lpKeyName As
Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Public Sub initGmailAccount(TheFile As String, TheSection As Variant, fForm As Variant,


fTimer As Variant, ftxtBox As Variant, fInet As Variant)
On Error GoTo ERRR

m_TheFile = TheFile
m_TheSection = TheSection
Set pForm = fForm: Set pTimer = fTimer: Set ptxtBox = ftxtBox: Set pInet = fInet

Log “INI: ” & m_TheFile & vbCrLf & “Section: ” & m_TheSection

pTimer.Enabled = False ‘stop the timer!


pTimer.Interval = SimpleGet(“interval”) * 1000 ‘set the timer!
pTimer.Enabled = True ‘start the timer!
Log “Interval: ” & pTimer.Interval / 1000 & ” seconds”

Username = SimpleGet(“username”)
Log “Username: ” & Username

Password = SimpleGet(“password”)
Log “Password: **********”
Log “Settings Loaded…”

Exit Sub
ERRR:
Log “Error in LoadSettings: ” & Err.Description
Resume Next
End Sub

http://duino4projects.com/arduino-visual-basic-6-light-controller/ 3/6
11/3/2016 Arduino & Visual Basic 6 Light Controller -Use Arduino for Projects

Public Function CheckMail(ByVal ToTextFile As String) As Boolean


On Error GoTo ERRR ‘error handling. a must.

Dim STRTemp As String ‘in “strtemp” we put the whole web page
Dim mailCount As String, mailTitle As String, mailSummary As String

STRTemp = pInet.OpenURL(“https://” & Username & “:” & Password &


“@mail.google.com/gmail/feed/atom”)
STRTemp = UCase(STRTemp)
mailCount = Right(STRTemp, Len(STRTemp) – InStr(1, STRTemp, “FULLCOUNT”) – 9)
mailCount = Left(mailCount, InStr(1, mailCount, “<“) – 1)
mailTitle = Right(STRTemp, Len(STRTemp) – InStr(1, STRTemp, “TITLE>L”) – 5)
mailTitle = Left(mailTitle, InStr(1, mailTitle, “<“) – 1)

If StrComp(mailTitle = “LIGHTCONTROL”, vbTextCompare) = 0 & mailCount = “1” Then


mailSummary = Right(STRTemp, Len(STRTemp) – InStr(1, STRTemp, “SUMMARY”) – 7)
mailSummary = Left(mailSummary, InStr(1, mailSummary, “<“) – 1)

‘load message into public variable


iTemp() = Strings.Split(mailSummary, “;”)

‘save mail data into a textfile


Open ToTextFile For Output As #1
Dim i As Integer
For i = LBound(iTemp()) To UBound(iTemp())
Print #1, iTemp(i)
Next
Close #1
CheckMail = True

Else
Log “Mail not available!!!”
CheckMail = False
End If

Exit Function
ERRR:
Log “Error in CheckMail: ” & Err.Description
Resume Next
End Function

http://duino4projects.com/arduino-visual-basic-6-light-controller/ 4/6
11/3/2016 Arduino & Visual Basic 6 Light Controller -Use Arduino for Projects

Public Sub Log(Text As String)


On Error GoTo ERRR
ptxtBox.Text = Text & vbCrLf & ptxtBox.Text
Exit Sub
ERRR:
MsgBox “Error while logging: ” & Err.Description
Resume Next
End Sub

Public Function SimpleGet(VarName As String) As String


Static sLocalBuffer As String * 500
Dim l As Integer

l = GetPrivateProfileString(m_TheSection, VarName, vbNullString, sLocalBuffer, 500,


m_TheFile)
SimpleGet = Left$(sLocalBuffer, l)

End Function

Public Sub SimplePut(TheItem As Variant, TheVal As Variant)

Call WritePrivateProfileString(m_TheSection, CStr(TheItem), CStr(TheVal), m_TheFile)


‘Flush buffer
Call WritePrivateProfileString(0, 0&, 0&, m_TheFile)

End Sub

Major Components in Project


Arduino

For more detail: Arduino & Visual Basic 6 Light Controller

This Post / Project can also be found using search terms:

yhs-per_003
arduini uno connect to vb6
arduino visual basic 6 0: make your own software to control arduino robot
arduino vb 6

Tw eet 0 1 StumbleUpon
subm it
Submit
Like Share

http://duino4projects.com/arduino-visual-basic-6-light-controller/ 5/6
11/3/2016 Arduino & Visual Basic 6 Light Controller -Use Arduino for Projects

‹ P rev i o u s Nex t ›

Project Ratings:

(1 votes, average: 5.00 out of 5)

Related posts

B a r G ra ph D rive with PID MID I Line a r Inte rfa c ing E M-18


C ontrol on a n A c tua tor RFID re a de r with
A rduino Me g a 2560 A rduino U no

Leave a Comment

Name*

Email*

Website

Submit Comment

(Spamcheck Enabled)

U P D AT E S AN D LAT E S T FACE B O O K AD V AN CE S E AR CH LAS T V I S I T E D :

Google Search Engine for Arduino


Select Category: Interactive Stereoscopic
Arduino Simulators
Arduino Projects…
3773 mentions J’aime Installations: visual
Arduino Project List in PDF Select a Category
rupture with the
Arduino Resources Glossary
Diplopiascope
Arduino Boards Selector Tool J’aime cette Page Partager Enter Search Terms:
Ultraviolet nightlight,
Search for...
Soyez le premier de vos amis à aimer
ingredients and setup
ça.

Search
An Arduino Powered
(Scale) Speed Trap

© 2013 Powered By Wise Technologies, Use Arduino for Projects | Sitemap | Privacy Policy

http://duino4projects.com/arduino-visual-basic-6-light-controller/ 6/6

You might also like