Help Coding Tower LED Light in VBA

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ISaunders
 
Posts: 4
Joined: Sat Mar 18, 2023 11:04 pm

Help Coding Tower LED Light in VBA

Post by ISaunders »

Hi Guys,

Trying to get my first purchase from Adafruit to work. I have been attempting to control the USB Tower Light that I bought (part # 5125)

I have the light installed on my Windows Computer using the USB port (COM5). I have tried two different VBA modules that send commands to COM5. I am making connections with the port and sending data to the light.

I am programming in the latest version of MS Access using VBA. You guys do have a Python example, but I need it to work in VBA.

The light is responding, but not correctly. I have tried using the HEX function in VBA. I have tried to use constants. I have tried to send the codes directly in quotes.

I can get it to blink and change colors, but just not correctly. It just seems like some of my codes are getting jumble or concatenated somehow.

Could you possibly make a suggestion as to what I am doing wrong or point me in the right direction? I can post the entire Communication module I am using, but it is very lengthy. Since I am making contact with the light, I thought someone might have had this issue before and maybe point me in the right direction.

Thank you in advance.

Gratefully,

Ira Saunders

Below is my code:
Private Sub Command0_Click()
Dim intPortID As Integer ' Ex. 1, 2, 3, 4, 5 for COM1 - COM5
Dim lngStatus As Long
Dim strError As String
Dim strData As String


Dim RED_ON As String
RED_ON = Hex(11) '"0x11"
Dim RED_OFF As String
RED_OFF = Hex(21) '"0x21"
Const RED_BLINK = "0x41"

Const YELLOW_ON = "0x12"
Dim YELLOW_OFF As String
YELLOW_OFF = Hex(22) '0x22
'YELLOW_BLINK = 0x42

'GREEN_ON = 0x14
Dim GREEN_OFF As String
GREEN_OFF = Hex(24) '0x24
Dim GREEN_BLINK As String
GREEN_BLINK = Hex(44)

'BUZZER_ON = 0x18
'BUZZER_OFF = 0x28
'BUZZER_BLINK = 0x48
' Initialize Communications
lngStatus = CommOpen(5, "COM" & CStr(5), "baud=9600 parity=N data=8 stop=1")
If lngStatus <> 0 Then
' Handle error.
lngStatus = CommGetError(strError)
MsgBox "COM Error: " & strError
End If


' Set modem control lines.
lngStatus = CommSetLine(5, LINE_RTS, True)
lngStatus = CommSetLine(5, LINE_DTR, True)

' Write data to serial port.
'MsgBox CommWrite(5, Hex(12)) 'Blinking Orange
'MsgBox CommWrite(5, Hex(42)) 'blinking red
'MsgBox CommWrite(5, Hex(22)) 'does nothing
'MsgBox CommWrite(5, Hex(44)) 'blinking yellow
'MsgBox CommWrite(5, Hex(10)) 'blinking red
'MsgBox CommWrite(5, Hex(18)) 'nothing
'MsgBox CommWrite(5, Hex(21)) 'blinking green
MsgBox CommWrite(5, Hex(24)) 'does nothing

CommClose (5)
End Sub

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”