Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to connect an electrical switch to my vb.net application via USB port?

How to connect an electrical switch to my vb.net application via USB port?

Scheduled Pinned Locked Moved Visual Basic
tutorialcsharpquestion
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aeskan
    wrote on last edited by
    #1

    Hi guys, I've read articles about; "Sending and receiving data from RS232 or USB ports" or, "Using vb.net to switch on/off electrical devices", but conversely in my case I want to just using a simple electrical switch to do something in my vb.net application (via RS232 or USB port). For example; if user pushed an electrical switch button which is connected to the RS232 or USB port, then simply a text same as "Pushed" appear in my application's text box. Briefly, could we connect an electrical switch without any circuit or board to USB port to do something simple in our application? Any suggestion or experience? Thanks.

    L D D 4 Replies Last reply
    0
    • A aeskan

      Hi guys, I've read articles about; "Sending and receiving data from RS232 or USB ports" or, "Using vb.net to switch on/off electrical devices", but conversely in my case I want to just using a simple electrical switch to do something in my vb.net application (via RS232 or USB port). For example; if user pushed an electrical switch button which is connected to the RS232 or USB port, then simply a text same as "Pushed" appear in my application's text box. Briefly, could we connect an electrical switch without any circuit or board to USB port to do something simple in our application? Any suggestion or experience? Thanks.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Short answer: No. Longer answer: you would need some interface between the switch and the computer's port that converted the elctrical current into the correct signals for the computer. Try searching Google for computer switches to see the sort of devices that are asvailable.

      Use the best guess

      A 1 Reply Last reply
      0
      • A aeskan

        Hi guys, I've read articles about; "Sending and receiving data from RS232 or USB ports" or, "Using vb.net to switch on/off electrical devices", but conversely in my case I want to just using a simple electrical switch to do something in my vb.net application (via RS232 or USB port). For example; if user pushed an electrical switch button which is connected to the RS232 or USB port, then simply a text same as "Pushed" appear in my application's text box. Briefly, could we connect an electrical switch without any circuit or board to USB port to do something simple in our application? Any suggestion or experience? Thanks.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        aeskan wrote:

        Briefly, could we connect an electrical switch without any circuit or board to USB port to do something simple in our application?

        No, as a USB port doesn't know how to interpret a "row" of switches. There's various projects, with prebuild general-purpose controllers and open source to control the hardware, like this one[^]. Alternatively, find a cheap USB-joystick and a large hammer :)

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        A 1 Reply Last reply
        0
        • A aeskan

          Hi guys, I've read articles about; "Sending and receiving data from RS232 or USB ports" or, "Using vb.net to switch on/off electrical devices", but conversely in my case I want to just using a simple electrical switch to do something in my vb.net application (via RS232 or USB port). For example; if user pushed an electrical switch button which is connected to the RS232 or USB port, then simply a text same as "Pushed" appear in my application's text box. Briefly, could we connect an electrical switch without any circuit or board to USB port to do something simple in our application? Any suggestion or experience? Thanks.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Connect a switch to a USB "port", hit the switch just once and you'll short the USB out and possibly kill the USB controller on your motherboard. USB ports are not "ports". USB is a BUS, not unlike the expansion slots (bus) inside your PC. Without an interface chip on the switch to tell USB that a device is there, you cannot listen for the changes in the switch.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak

          A 1 Reply Last reply
          0
          • A aeskan

            Hi guys, I've read articles about; "Sending and receiving data from RS232 or USB ports" or, "Using vb.net to switch on/off electrical devices", but conversely in my case I want to just using a simple electrical switch to do something in my vb.net application (via RS232 or USB port). For example; if user pushed an electrical switch button which is connected to the RS232 or USB port, then simply a text same as "Pushed" appear in my application's text box. Briefly, could we connect an electrical switch without any circuit or board to USB port to do something simple in our application? Any suggestion or experience? Thanks.

            D Offline
            D Offline
            dusty_dex
            wrote on last edited by
            #5

            As other have already pointed out. Direct connection to USB is hazardous to the health of the USB ports. However, perhaps if you got hold of a USB-Serial adapter it should be possible to use it on the Carrier Detect/CTS/RTS/DTR/DTS. whichever is available at the serial port. an additional smoothing capacitor & resistor above 1K-ohms in series should help filter out the switching noise/limit current demand.

            A 1 Reply Last reply
            0
            • D dusty_dex

              As other have already pointed out. Direct connection to USB is hazardous to the health of the USB ports. However, perhaps if you got hold of a USB-Serial adapter it should be possible to use it on the Carrier Detect/CTS/RTS/DTR/DTS. whichever is available at the serial port. an additional smoothing capacitor & resistor above 1K-ohms in series should help filter out the switching noise/limit current demand.

              A Offline
              A Offline
              aeskan
              wrote on last edited by
              #6

              Thank you dusty_dex, that's what I was searching for. :-D

              1 Reply Last reply
              0
              • D Dave Kreskowiak

                Connect a switch to a USB "port", hit the switch just once and you'll short the USB out and possibly kill the USB controller on your motherboard. USB ports are not "ports". USB is a BUS, not unlike the expansion slots (bus) inside your PC. Without an interface chip on the switch to tell USB that a device is there, you cannot listen for the changes in the switch.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak

                A Offline
                A Offline
                aeskan
                wrote on last edited by
                #7

                Thanks Dave.

                1 Reply Last reply
                0
                • L Lost User

                  aeskan wrote:

                  Briefly, could we connect an electrical switch without any circuit or board to USB port to do something simple in our application?

                  No, as a USB port doesn't know how to interpret a "row" of switches. There's various projects, with prebuild general-purpose controllers and open source to control the hardware, like this one[^]. Alternatively, find a cheap USB-joystick and a large hammer :)

                  Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                  A Offline
                  A Offline
                  aeskan
                  wrote on last edited by
                  #8

                  Thank you Eddy for reply.

                  1 Reply Last reply
                  0
                  • L Lost User

                    Short answer: No. Longer answer: you would need some interface between the switch and the computer's port that converted the elctrical current into the correct signals for the computer. Try searching Google for computer switches to see the sort of devices that are asvailable.

                    Use the best guess

                    A Offline
                    A Offline
                    aeskan
                    wrote on last edited by
                    #9

                    Thanks Richard.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups