DPaul
Posts: 97
Joined: Fri Oct 13, 2017 7:39 am

mini usb leds

Fri Jan 05, 2018 10:09 am

Hi,

Before i do anything stupid:

I have a number of USB mini flex lights, the kind that you stick into your laptop for lighting the keyboard.
Like so:
https://www.amazon.com/Flexible-USB-Lig ... B0191S9I4K

For my project i plan to use a Pi zero W, where i am in short supply of USB ports.
But i need a lamp illuminating the keypad on the device i am making (attempting to make)

Question: can i take one of these Led lights, cut the usb connector, and connect it to a GPIO pin / 5 volts / resistor combo,
just like any other led ? Or is there a more clever alternative?

An added benefit for me (as opposed of having a permanent USB connected light) would be that i can write a script
that turns the lamp on and off, when the user needs to do something or sit idle.
?

thx,
Paul

pcmanbob
Posts: 7306
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: mini usb leds

Fri Jan 05, 2018 11:04 am

You could cut the end off but you don't know what your will find inside may not be easy to connect to external supply, but if your project is in some sort of case why not mount a USB socket in the case so you can just plug your lamp in to it.

Then you can power the socket via a transistor from the 5v pin on the gpio which will allow you to turn it on and off using a gpio pin controlling the transistor.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

DPaul
Posts: 97
Joined: Fri Oct 13, 2017 7:39 am

Re: mini usb leds

Sat Jan 06, 2018 11:03 am

Thx, good idea, i did not know those things could be purchased as sockets.
They seem to have 4 contacts. Now i just have to find a wiring scheme :)

Paul

pcmanbob
Posts: 7306
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: mini usb leds

Sat Jan 06, 2018 11:13 am

The socket is classed as the male in this diagram.
Attachments
usb.jpg
usb.jpg (28.67 KiB) Viewed 1754 times
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

DPaul
Posts: 97
Joined: Fri Oct 13, 2017 7:39 am

Re: mini usb leds

Sun Jan 07, 2018 7:47 am

Wow, thanks.

Using all of my three-month experience with these matters,
am i correct in guessing:

a) This is a front view
b) 99% of those usb sockets in the world have the same layout
c) I leave the data pins alone
d) if i choose to control on/off programmatically,
i can do that like any other little led lamp via a 330 ohm resistor to ground.
e) Vcc being the 5 volt pin.

Paul

User avatar
rpdom
Posts: 15608
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: mini usb leds

Sun Jan 07, 2018 8:10 am

DPaul wrote:
Sun Jan 07, 2018 7:47 am
a) This is a front view
Yes.
b) 99% of those usb sockets in the world have the same layout
No. 100% of USB sockets have the same layout. It is a standard.
c) I leave the data pins alone
Yes.
d) if i choose to control on/off programmatically,
i can do that like any other little led lamp via a 330 ohm resistor to ground.
No. They will already have a resistor built in to the unit. They will require 5 Volts at around 240mA to work properly. To control that programmatically you would need to use a transistor to switch the 5V from a 3.3V GPIO pin.
e) Vcc being the 5 volt pin.
Yes.

I'm now curious to see what is inside those LED units, so I've ordered a few to play with. I'll find out in a few weeks :-)

DPaul
Posts: 97
Joined: Fri Oct 13, 2017 7:39 am

Re: mini usb leds

Sun Jan 07, 2018 8:23 am

OK, thanks.
Got my Pi zero W in yesterday, so i know what to do in the next few days :D

Paul

pcmanbob
Posts: 7306
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: mini usb leds

Sun Jan 07, 2018 12:31 pm

All you need is a 470 ohm resistor and a 2n2222 transistor wired to the gpio and USB socket like this.

Image

you can use any of the gpio pins to control this with a simple python program.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

DPaul
Posts: 97
Joined: Fri Oct 13, 2017 7:39 am

Re: mini usb leds

Sun Jan 07, 2018 3:39 pm

Could a NPN BC548 transistor do ?
Got a bunch of them

thx,
paul

pcmanbob
Posts: 7306
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: mini usb leds

Sun Jan 07, 2018 3:47 pm

DPaul wrote:
Sun Jan 07, 2018 3:39 pm
Could a NPN BC548 transistor do ?
Got a bunch of them

thx,
paul
BC548 is only rated for 100mA
2n2222 is rated at 800mA

your lights 240-260mA so no BC548 wont do.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

DPaul
Posts: 97
Joined: Fri Oct 13, 2017 7:39 am

Re: mini usb leds

Sun Jan 07, 2018 4:41 pm

Another 90 eurocent investment ! :shock:

Paul

DPaul
Posts: 97
Joined: Fri Oct 13, 2017 7:39 am

Re: mini usb leds

Tue Jan 09, 2018 8:36 am

I have found an inordinate amount of usb sockets on the net.
Some even are "power socket only". No data !

If you want one that is also "easy to install in a small case", it's rare.
(Not if you want to pay lots of money (relatively)). It's actually a lot
cheaper to buy a 5 slot usb hub.

Because, if i solder the "USB type A" to the PCB,
it becomes more difficult to plug the LCD lamp, and get it back out again.
It is supposed to be user friendly.

Maybe dismantling a cheaper usb hub could be a solution.
You get 4 or 5 sockets in one go....

Paul

pcmanbob
Posts: 7306
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: mini usb leds

Tue Jan 09, 2018 10:32 am

Don't know were in the world you are but you can get them from china for 99P
https://www.ebay.co.uk/itm/Magic-USB-5p ... SwdGFYrVCn
https://www.ebay.co.uk/itm/USB-2-0-A-Ma ... SwRH5XKbUN

the first one is actually the same both ends so you could cut it in half and end up with 2 sockets !
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
Mortimer
Posts: 924
Joined: Sun Jun 10, 2012 3:57 pm

Re: mini usb leds

Tue Jan 09, 2018 10:49 am

It looks like a solution to use a USB socket is being followed.

In case there was any doubt however, the other thing to be careful of with USB powered devices, is that often the USB plug body is where electronics is hidden. It is unlikely in this case, although there might be a resistor or constant current circuit inside the plug, and by cutting this off, something may have been lost that protects the LEDs.
--------------
The purpose of a little toe is to ensure you keep your furniture in the right place.

DPaul
Posts: 97
Joined: Fri Oct 13, 2017 7:39 am

Re: mini usb leds

Tue Jan 09, 2018 11:18 am

Yes , i have seen the ones on the ebay UK site, but shipping is from Hong-Kong.
They will take a month or more to get here. (here = where i can almost see Albion)
Who has that kind of patience ? :?

Dismantling has ben done on youtube of course :
https://www.youtube.com/watch?v=4RfMiyjQ12s

fun!

Paul

DPaul
Posts: 97
Joined: Fri Oct 13, 2017 7:39 am

Re: mini usb leds

Fri Jan 12, 2018 10:40 am

pcmanbob wrote:
Tue Jan 09, 2018 10:32 am
Don't know were in the world you are but you can get them from china for 99P
https://www.ebay.co.uk/itm/USB-2-0-A-Ma ... SwRH5XKbUN
I ended up buying these. I ordered 5 for the price of 1 i found locally.
When i cut the cord, i hope to find the right wires ;)

Paul

DPaul
Posts: 97
Joined: Fri Oct 13, 2017 7:39 am

Re: mini usb leds

Fri Feb 09, 2018 8:33 am

At long last they have arrived from China!
Seem to bee very OK.
I cut off one end and stripped the wires, to find the 4 colors i was expecting.

Image

Next stop, add some usb ports to the pie zero !

Paul

User avatar
Mortimer
Posts: 924
Joined: Sun Jun 10, 2012 3:57 pm

Re: mini usb leds

Fri Feb 09, 2018 4:57 pm

I would still buzz them out, it is not unknown for wires to be swapped in low cost Chinese sourced components.
--------------
The purpose of a little toe is to ensure you keep your furniture in the right place.

Return to “Beginners”