# Home Automation - USB Relay Controller

Status
Not open for further replies.

#### electrolearner

##### Newbie level 5
Hi
I am working on home automation project (for fun ) and trying to control appliances using this USB Relay Controller by Protosmart in Visual basic. I have tested the board with provided software & it all works fine.
Also, I tried controlling the relays using hyper terminal and they worked as expected.
Now, I am programming in visual basic (am a beginner) to control the Relays and dont know how to send <ENTER> ?

Relays can be controller by sending very simple commands. For example,

O0=1<ENTER> turns on Relay 1

and I am not sure how to send "enter" key?

I will appreciate any help in this regards.

Thanks

The question is refering to the PC side programming, moved to PC Programming and Interfacing [Alexan_e]

##### Super Moderator
Staff member
The BASIC language has a keyword named INPUT.

Typical syntax is:
INPUT a
or
INPUT a\$

The program then halts as you type the keys for the number or letters you want. Then press the 'return' or 'enter' key. The variable is given the value you input.

If you don't want the program to halt, then you cannot use 'INPUT'. Instead you must periodically check for keypresses with a different command. It might be something like 'INKEY' or "GETKEY", etc. This is called polling.

Check your Visual Basic manual to see what code it gives the 'enter' key. It probably has the ascii value of 13 (carriage return).

It may be tricky to use polling. You will have to detect all keypresses.

You'll have to string separate keypresses together. You'll have to store it in a variable, on the chance the next keypress is the 'Enter' key.

Then you'll have to process the string to see if it's made up of letters or numbers, etc.

Last edited:

#### FvM

##### Super Moderator
Staff member
The BASIC language has a keyword named INPUT.
I fear, the question is very unclear. It's actually asking how to send a specific string to the COM port. "<ENTER>" is somewhat misleading, because it obviously means carriage return, or a carriage return/linefeed combination.

#### horace1

for the end of line combination you can use vbCRlf, e.g. using the SerialPort component in Visual Studio 2010
Code:
SerialPort1.Write(vbCrLf)

#### electrolearner

##### Newbie level 5
for the end of line combination you can use vbCRlf, e.g. using the SerialPort component in Visual Studio 2010
Code:
SerialPort1.Write(vbCrLf)

Many thanks. Exactly what I needed (vbCr).

(I needed <CR> only)

Status
Not open for further replies.

Replies
14
Views
4K
Replies
8
Views
1K
Replies
0
Views
1K
Replies
1
Views
1K
Replies
15
Views
8K