Android Question How to light on a led on usb port ?

GDO

Member
Licensed User
Longtime User
Hi,
I'ld like to light on/off a led on usb port (on android device).
My first thought was to use an arduino (chip not board) and an usb library but is there a simplier way to do that ?
Thank you for your help.
 

GDO

Member
Licensed User
Longtime User
An Arduino is a good solution as it includes a USB to serial chip. You can then use felUsbSerial library on the B4A side and write a simple B4R program that will control the led.
Thanks.
But is there something simplier ? Without arduino (i use attiny, no usb to serial chip) ?
I google a lot and FTDI bitbang mode seems to be a solution.
is it possible to use it with felUsbSerial library ?
 
Upvote 0

giga

Well-Known Member
Licensed User
Longtime User
felusbserial library is working for me with a Digispark (attiny 45) and Initialize2(..."CDCSerialDevice"...)
Thank you for your help
:)
Are you using an OTG cable with this or does the Digispark plug directly into the USB connection on the phone/device?
 
Upvote 0

GDO

Member
Licensed User
Longtime User
Are you using an OTG cable with this or does the Digispark plug directly into the USB connection on the phone/device?
Directly into the USb --> OK
With a male/female usb cable --> OK
(both on a minix 5, waiting for a female/female usb for my phone)
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
you can use HC-6 Bluetooth module and connect it to your led board.. your led board must have RS485 port, then connect the four pins of the CH-6 to your boards serial port.

bt2hc6.jpg
 
Last edited:
Upvote 0

Beja

Expert
Licensed User
Longtime User
Any special reason to need a USB port when you can turn the LED "ON" wirelessly by Bluetooth? I thought BT is more convenient because no wires required
besides it goes further than USB cable.
 
Upvote 0

GDO

Member
Licensed User
Longtime User
Any special reason to need a USB port when you can turn the LED "ON" wirelessly by Bluetooth? I thought BT is more convenient because no wires required
besides it goes further than USB cable.
Wireless means with battery ...
 
Upvote 0

GDO

Member
Licensed User
Longtime User
Some detailed information about your Android device can help.
Thank you for your help.
I am not asking for help about arduino but help to skip arduino.

I just need to turn on/off a led (or maybe 2) on a minix (or something like that).
I was looking for the best way to do that as cheap and simple as possible.

HC-05 or 06, and esp8266 are OK, Arduino too.
Digispark (3$ on ebay) is working but with programmation on it.
FTDI bitbang mode (with no programmation on it) seemed to be the best choice, but it's not working, now.

Can somebody help me with FTDI bitbang mode and B4A ?

All answers are welcome.

:)

Digispark picture :
upload_2016-5-24_16-55-42.png
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Still the tech specs of your led board is important.. Because you want to interface to the board then it's important to know the pinout of the board and inner finctions if sny.
If you just want to turn on and off single led then you can use the audeo jack, send audio frequency from the phone and rectify it with bridge diode and connect the out to tge led.. If multiple leds you can send different frequencies and filter them in the led board and then send tge dc signsl to the different leds.
 
  • Like
Reactions: GDO
Upvote 0

GDO

Member
Licensed User
Longtime User
Still the tech specs of your led board is important.. Because you want to interface to the board then it's important to know the pinout of the board and inner finctions if sny.
If you just want to turn on and off single led then you can use the audeo jack, send audio frequency from the phone and rectify it with bridge diode and connect the out to tge led.. If multiple leds you can send different frequencies and filter them in the led board and then send tge dc signsl to the different leds.
Thanks.
It sounds good.
I don't know how to rectify frequency but I'll google it, and try it if possible.
:)
 
Upvote 0
D

Deleted member 103

Guest
Hi guys,

has anyone managed to establish a connection with a Digispark?
If yes, how?
I have tried it with the library felUsbSerial, unfortunately without success.
 
Upvote 0

GDO

Member
Licensed User
Longtime User
can you tell me how you did it?
Hello,
Could you tell me what is not working exactly ?

Is this helpfull ?

B4X:
Sub Process_Globals
    Private usbserial As felUsbSerial
    Private manager As UsbManager
...

Sub Service_Create
    manager.Initialize
    GetUsb
...

Sub GetUsb
    ' Pas de USb ?
    If manager.GetDevices.Length = 0 Then
        ToastMessageShow("Please connect usb device and try again.", True)
    Else
        ' Pas autorisation USB
        Dim device As UsbDevice
        For i=0 To manager.GetDevices.Length-1
            device = manager.GetDevices(i)
'    ToastMessageShow(i & " : " & device.VendorId & " - " & device.ProductId, True)
'            If device.VendorId = 5840 And device.ProductId = 1875 Then        ' Digispark 16d0=5840 et 0753=1875
            If device.VendorId = 5840 And device.ProductId = 2174 Then        ' Digispark 16d0=5840 et 087E=2174
                If manager.HasPermission(device) = False Then
                       ToastMessageShow("Please allow connection and try again.", True)
                    manager.RequestPermission(device)
                Else
                    UsbOk = True
                    usbserial.Initialize2("serial", device, -1, "CDCSerialDevice")   
                End If                   
            End If
            Exit
        Next   
    End If
End Sub
 
Last edited:
Upvote 0

Similar Threads

Top