Jump to content

analog hall effect sensor to control led strip

givingtnt

hi !

I have an arduino. and I want to use a hall effect sensor (analog) to gradually light up a led strip.

not in the dimming sense. I mean, the closer it comes, the more leds on the strip light up, as the rest is off.

 

how can I do that ?
do I have to get special led strips ?

I just need red. no need for rgb.

 

thanks !

~New~  BoomBerryPi project !  ~New~


new build log : http://linustechtips.com/main/topic/533392-build-log-the-scrap-simulator-x/?p=7078757 (5 screen flight sim for 620$ CAD)LTT Web Challenge is back ! go here  :  http://linustechtips.com/main/topic/448184-ltt-web-challenge-3-v21/#entry601004

Link to comment
Share on other sites

Link to post
Share on other sites

My understanding of LED strips is they all light up together, there's no way to turn on some but not others.

Solve your own audio issues  |  First Steps with RPi 3  |  Humidity & Condensation  |  Sleep & Hibernation  |  Overclocking RAM  |  Making Backups  |  Displays  |  4K / 8K / 16K / etc.  |  Do I need 80+ Platinum?

If you can read this you're using the wrong theme.  You can change it at the bottom.

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Ryan_Vickers said:

My understanding of LED strips is they all light up together, there's no way to turn on some but not others.

then how do you do this ? 

 

~New~  BoomBerryPi project !  ~New~


new build log : http://linustechtips.com/main/topic/533392-build-log-the-scrap-simulator-x/?p=7078757 (5 screen flight sim for 620$ CAD)LTT Web Challenge is back ! go here  :  http://linustechtips.com/main/topic/448184-ltt-web-challenge-3-v21/#entry601004

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, givingtnt said:

hi !
I have an arduino. and I want to use a hall effect sensor (analog) to gradually light up a led strip.
not in the dimming sense. I mean, the closer it comes, the more leds on the strip light up, as the rest is off.

how can I do that ?
do I have to get special led strips ?
I just need red. no need for rgb.

thanks !

You'll need a programmable LED strip if you want it to light up gradually but most are RGb or to build yourself a shift register LED matrix. 

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, givingtnt said:

then how do you do this ? 

 

witchcraft /s

 

I assume those are special strips that allow addressing each LED individually.  Whether he managed to buy them like that or they're custom, I don't know, but I'm pretty sure most run of the mill strips used for case lighting can't do that

Solve your own audio issues  |  First Steps with RPi 3  |  Humidity & Condensation  |  Sleep & Hibernation  |  Overclocking RAM  |  Making Backups  |  Displays  |  4K / 8K / 16K / etc.  |  Do I need 80+ Platinum?

If you can read this you're using the wrong theme.  You can change it at the bottom.

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, givingtnt said:

then how do you do this ? 

 

1 hour ago, Ryan_Vickers said:

witchcraft /s

 

I assume those are special strips that allow addressing each LED individually.  Whether he managed to buy them like that or they're custom, I don't know, but I'm pretty sure most run of the mill strips used for case lighting can't do that

Yup, 5050 rgb leds are individually addressable through one aerial connection. They're really fantastic, I'm not sure why it took so long for motherboard manufacturers to get on that standard. 

ASU

Link to comment
Share on other sites

Link to post
Share on other sites

10 hours ago, Hackentosher said:

 

Yup, 5050 rgb leds are individually addressable through one aerial connection. They're really fantastic, I'm not sure why it took so long for motherboard manufacturers to get on that standard. 

Not true, 5050 describes the physical size of the LED not its electrical characteristics. Some 5050 LEDs have ASICs inside of them which allows them to be addressed individually. @Ryan_Vickers, @givingtnt Search for WS2812 or WS2811 on ebay, those are the cheapest addressable chipsets. You have to get the timing right since they don't use a clock signal. If you are going to use arduino I have written a rather handy code which allows to interface with the LEDs easily:

Here is the code on github: https://github.com/Dany-Boy55/Addressable-WS2812-LED-controller

However I think you dont want to interface the LEDs with a PC. In that case take a look at the FastLED library for arduino: https://github.com/FastLED/FastLED

Cheers!

Quote or tag if you want me to answer! PM me if you are in a real hurry!

Why do Java developers wear glasses? Because they can't C#!

 

My Machines:

The Gaming Rig:

Spoiler

-Processor: i5 6600k @4.6GHz

-Graphics: GTX1060 6GB G1 Gaming

-RAM: 2x8GB HyperX DDR4 2133MHz

-Motherboard: Asus Z170-A

-Cooler: Corsair H100i

-PSU: EVGA 650W 80+bronze

-AOC 1080p ultrawide

My good old laptop:

Spoiler

Lenovo T430

-Processor: i7 3520M

-4GB DDR3 1600MHz

-Graphics: intel iGPU :(

-Not even 1080p

 

Link to comment
Share on other sites

Link to post
Share on other sites

42 minutes ago, dany_boy said:

Snip 

Lol that's why I specified 5050 rgb. Still pretty cool what you can do with them.

ASU

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, Hackentosher said:

Lol that's why I specified 5050 rgb. Still pretty cool what you can do with them.

5050LED_vs_WS2812.jpg.caa4b15a1495db196934bce63b9a95cf.jpg

Both of these are 5050 LEDs (50mm x 50mm). The one on the left is an RGB, while the one on the right is a WS2812. Notice how the RGB one has 3 silicon dyes that are directly attached to the conductive pads in the component. Each dye is a PN junction coated with a different material to provide red green and blue colors. The ones on the left are found across most LED strips, the ones supported my Asus aura and so forth. The strips containing the aforementioned LEDs will light up with the same color across the entire strip.

Now take a closer look at the LED on the right. Notice that this one has 4 silicon dyes inside. The bigger one is an ASIC, designed to drive 3 leds with serial data.

Quote or tag if you want me to answer! PM me if you are in a real hurry!

Why do Java developers wear glasses? Because they can't C#!

 

My Machines:

The Gaming Rig:

Spoiler

-Processor: i5 6600k @4.6GHz

-Graphics: GTX1060 6GB G1 Gaming

-RAM: 2x8GB HyperX DDR4 2133MHz

-Motherboard: Asus Z170-A

-Cooler: Corsair H100i

-PSU: EVGA 650W 80+bronze

-AOC 1080p ultrawide

My good old laptop:

Spoiler

Lenovo T430

-Processor: i7 3520M

-4GB DDR3 1600MHz

-Graphics: intel iGPU :(

-Not even 1080p

 

Link to comment
Share on other sites

Link to post
Share on other sites

On 5/11/2017 at 7:48 AM, givingtnt said:

hi !

I have an arduino. and I want to use a hall effect sensor (analog) to gradually light up a led strip.

not in the dimming sense. I mean, the closer it comes, the more leds on the strip light up, as the rest is off.

 

how can I do that ?
do I have to get special led strips ?

I just need red. no need for rgb.

 

thanks !

LED Strips that can't be programmed (they have only voltage and ground wires) will not allow you to turn on or off segments of them, you can only adjust brightness by reducing the voltage they led strip receives within some range.

Basically most basic led strips are made of small segments of 3 or 4 leds ,each with their own current limiting resistor,m and these segments are connected to the input voltage :

 

[ +12v ] ======= [[  + led strip  ---- [ + led strip segment ... [ + led 1 - ]  [ + led 2 - ] [ + led 3 - ] [ resistor ] ... led strip segment - ] ---- [ next segment ]  ---- led strip - ]] ====  [ GND ] 

 

This makes it possible to cut led strips at any point after a 3 led segment.

 

Some RGB led strips have 4 wires,  RED , GREEN , BLUE and GND  or 5v/12v , RED , GREEN , BLUE - in the first scheme you send some voltage on each red, green or blue wire to turn on those leds in each LED chip. In the other scheme, there's always voltage on the 5v/12v wire and to make a color light up, you connect red, green or blue to ground (sink current).. and in both scenarios you can control the brightness using PWM (turn on and off lots of times a second and vary the amount of ON vs OFF time to adjust intensity)

 

More advanced led strips are made out of chips that each have a small chip in them which can receive a signal from your arduino and set the three leds to a particular brightness based on what you send.

These led strips typically have three or four wires: voltage , ground , data and maybe clock.

If the chips in the leds support a clock, every time you set a high voltage on clock wire and then down to no voltage, the chip knows to read the bit on the data wire so that's how you can send a bit at a time to the chip in the first led which then passes the bit along to the next led in the strip if it detects more bits are coming then it needs (daisy chain).

When there's no clock wire, the chips always assume you're sending bits at a specific frequency (around 400 kHz or 400000 bits a second) and in order for the chips to synchronize with the commands your arduino sends and to detect the exact frequency your arduino uses, you have to send a pattern of bits.

Luckily, you don't have to worry about it, as there are libraries already written by people who make this painless, those libraries give you very easy to use functions to individually control those leds in the strip.

If you want to make your own strip out of red leds then it can be very simple.

 

If you have just a few leds (for example let's say 8 leds), you can use the IO pins of your arduino that aren't used. Just put one led on each IO pin and one resistor to limit the current    R = (Vin - Vled) / current  .. for example for 10mA  then R = (5v - ~1.7v ) / 0.01 = ~ 330 ohm

So you get the result from the hall effect sensor to figure out how many leds you want to turn on and then set individual io pins to output 1 (send voltage) and turn on the led.

If you want more leds than the number of IO pins on your Arduino you can do multiplexing or you can use shift registers or you can use led drivers to control lots of leds.

 

In multiplexing, you can arrange leds in groups of leds, and work with one group of leds at a time. You take advantage of human eyes' particularity where you don't notice leds turning off and on if they're turned on and off fast enough.

So with multiplexing, you select which leds in a segment to turn on and off then activate this segment for some period of time (like 1ms), then deactivate this segment, set the leds you want to be on or off in the next segment and enable the next segment

 

multiplexing.png.a6f77d428a308972e0ff84cfa90e8b62.png

 

 

So basically each of those brown rectangles is made out of  8 leds, 8 resistors to limit the current going through each led  but instead of connecting each end of the resistor to ground like you'd normally do, you'd connect them together and then to the collector of a NPN transistor.

An NPN transistor is like a switch, when there's voltage on its base pin there's a connection made between the C and E pins, so all the resistors of the leds are connected to  ground through the NPN transistor.

So you can use 8 wires to daisy chain as many such groups of 8 leds but make only one of these groups of leds work by sending power to its npn transistor using a dedicated wire .. so if you have 3 groups of leds you only need 8 + 3 wires to control 24 leds.

The resistor on the base of the npn transistor is to limit the amount of energy going through the transistor, something like 10 ohm to 100 ohm is enough. NPN transistors are very sensitive, they could l be damaged if you connect that base pin directly to 5v without some resistance there.

 

So basically you set the leds to on or off in a group of 8 leds , send 1 through the SEG1 pin of your arduino to turn on the transistor and make the connection between resistors and ground (so the 8 leds will actually light up if you want them to), wait a very short time, turn off SEG1 to turn off all 8 leds, set the 8 leds to something else and send 1 through SEG2 wire to enable the next 8 leds, wait a very short time , then repeat this for the third group of leds and then go back to first group of leds.

If you cycle through this fast enough, human eyes don't notice that for some time within a second, some of those groups don't light up

 

Shift registers are basically chips that take in a series of bits (let's say 8 bits) and have 8 outputs  and they can be daisychained ... ex you have 8 such chips so you send 64 bits through two wires to those chips and then you send an  "enable" signal through a third wire and then the chips set  all their 8x8 outputs to what bit you sent ... so you can control 64 leds with 3 wires.  You still need a led and a resistor on the output of each shift register to limit the current.. it's more expensive and a shift register takes more space on a led strip for example but on the other hand you only use 3 wires instead of 8+1 for each group and you don't need an npn transistor..

 

led drivers.. well led drivers can control up to 16-32 leds, they control the led current so you don't need resistor for each led making the circuit simpler, some can be daisy chained , some can let you adjust brightness per led independently just by sending a couple of bytes to the chip so they make your life easier. They're usually more expensive than shift registers or a simple npn transistor

 

 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×