Android Question How to observe a simple switch status using usb-port?

johnerikson

Active Member
Licensed User
Longtime User
Hallo innovators!
Is it possible to connect an USB-Cable to the USB–port and pull it together with a simple switch and detect on/off status in an B4a App – code?

In possible, how to connect cables and write the code? What libraries is needed?
Case else some other suggestions, please!

Johneriksson

upload_2014-8-12_21-14-23.png
 

Attachments

  • upload_2014-8-12_21-12-26.png
    upload_2014-8-12_21-12-26.png
    237 bytes · Views: 123

sorex

Expert
Licensed User
Longtime User
Not sure if you can do it straight on the port but you might need a usb > ttl/rs232 cable that works like an uart modem. (costs a few euros)

Problem here is that they are usually old fashioned USB and not micro/mini USB.

There are bluetooth/wifi modules with jumper like pins on that might help you aswell to detect shortcuts between the pins (arduino or not, rasPi extention boards or others)

Edit:
here's a tiny board > https://www.pjrc.com/teensy/first_use.html
 
Last edited:
Upvote 0

johnerikson

Active Member
Licensed User
Longtime User
Thank you for the answer!

I feel a little confuse because I not have knowledge about such hardwere as bluetooth/wifi modules. After I had google about bluetooth/wifi modules I Think usb -> yyl/rd232 is the easiest way to a solution.

http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm
Do you think that link point on a applicable Product for a ttl/rs232 solution?

In that case I trying that way. There is probably still a long road ahead, select lib and make code etc.
without some example.
I hope someone have worked with near solutions!

/Johneriksson
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
regarding that cable, it's way overprices on that site. you could get it for 2 pound or so.

I have one of those for flashing some hardware so I can give you a link from where I got it cheap.

jsanchezc had also a good point, that IOIO toy seems to be usefull for you as it is simular than what I posted earlier but for sure working with Android.
And there is the IOIO library for B4A to use with the hardware.

http://www.seeedstudio.com/depot/IOIO-OTG-for-Android-p-1615.html

Might get me one of these to play with aswell.
 
Upvote 0

johnerikson

Active Member
Licensed User
Longtime User
Thanks!
it's very intresting, useful and fun to play with IOIO, but I Think it is like to hunt flies wit a gun for elephants. The only thing I need is to detect a cilck on a external buttom in my App.
So I try to solve it with ttl/rs232. In the moment I have solved it by using headphone Connection, transmit a beep with and catch the sound with Recordreading functions when the switch is on. I'm not satisfied with the that solution because it is'nt stable.
Sorry about my bad English, hope you uderstand!
/Johneriksson
 
Upvote 0
Top