The Living Colors lamp is controled via a terminal program like HyperTerm. The downside of this is that the commands can't be scripted. To overcome this problem i use this small piece of code.
Code: Select all
Public Sub Main(ByVal Parms As Object)
'-------------------------
'Get commandline arguments
'-------------------------
Dim CmdLine = Parms & Chr(13)
Dim ComPort = 6 'Use this com port
hs.CloseComPort(ComPort) 'Close the serial port in case it's hanging
hsp.WaitMS(400) 'Sometimes fails to obtain a
handle if there is no pause
Dim Status
Status = hs.OpenComPort(ComPort, "9600,n,8,1", 1, "", "")
If Status <> "" Then
hs.writelog("Error opening COM" & ComPort, Status)
Else
hs.writelog("COM6", "Com port" & ComPort & " setup complete")
End If
hsp.WaitMS(2000) 'Wait for the Arduino to get ready
'---------------------------------------------------------------------------------------------------------
' Arduino serial buffer cannot take more than 32 characters;
' writing a character to eeprom takes about 11 ms (assuming
that there is no serial.prints in the loop);
' therefore, after each batch of 10 chars sent to COM, we
should wait no less than 110 ms;
'---------------------------------------------------------------------------------------------------------
hs.SendToComPort(ComPort, CmdLine)
hsp.WaitMS(4000) 'Let the Arduino process the data
hs.CloseComPort(ComPort) 'Close the serial port
End Sub