Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Home Automation - USB Relay Controller

Status
Not open for further replies.

electrolearner

Newbie level 5
Joined
Jul 12, 2009
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,331
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]
 

BradtheRad

Super Moderator
Staff member
Joined
Apr 1, 2011
Messages
13,975
Helped
2,786
Reputation
5,570
Reaction score
2,693
Trophy points
1,393
Location
Minneapolis, Minnesota, USA
Activity points
104,247
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
Joined
Jan 22, 2008
Messages
48,198
Helped
14,203
Reputation
28,665
Reaction score
12,898
Trophy points
1,393
Location
Bochum, Germany
Activity points
279,221
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

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,071
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
Joined
Jul 12, 2009
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,331
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top