Arduino Uno Hall Ef...
 
Notifications
Clear all

Arduino Uno Hall Effect magnet proximity indicator using 10 LEDs.

18 Posts
4 Users
2 Likes
2,497 Views
AV8R-Guy
(@av8r-guy)
Member
Joined: 2 years ago
Posts: 8
Topic starter  

Hello, I’m new to this workshop and could use some help.  I am wanting to build a circuit that shows the exact position of a magnet (by lighting a particular LED) as it passes by a KY-024 Hall Effect sensor, attached to an Arduino Uno.

If the magnet is to the far left, #1 LED would light up.  As the magnet moves to the right, #2 would then light.  As the magnet is moved more to the right, then #3, then #4, etc, etc.  Of course, as the magnet moved back toward the left, each appropriate LED for its position would light up.  This circuit has lots of practical applications, where the builder can attach a magnet to a rod, or rotating wheel and an LED would indicate the exact position of the rod, wheel, etc. in relation to the sensor.

I have researched and can’t find anything that accomplishes what I’m after.  The Arduino.CC website has something that might come close, but I’m not sure if it can be modified to do what I want.  It is the LED bar graph example.  I wonder if instead of using a potentiometer for the incoming analog signal, the experimenter could swap a KY-024 sensor in its place.

Thanks for any assistance you might offer.


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6829
 

I know I have encountered that type of device in the real world, just can't remember where. The only problem you will have is deciding how many points of the compass you want to position magnets at as I am sure each one will take up a pin. An UNO might not have enough, but what about a Mega?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2506
 

@av8r-guy

Using Hall effect sensors is covered in Bill's excellent adventure ...

 

They are quite simple to use, but as @ronalex4203 says, picking a number and getting enough pins may be a totally different adventure 🙂

HINT: shift registers 🙂

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
AV8R-Guy
(@av8r-guy)
Member
Joined: 2 years ago
Posts: 8
Topic starter  

@ronalex4203 , I may have failed to mention it takes 10 LEDs.  The sample shown on Arduino.CC has 10 LEDs plugged directly into the Uno.

There is a real world version of this circuit, but I would rather use an Arduino.  From what I’ve found, I think  the Arduino.CC “LED bar graph” circuit comes close.  If I understand it correctly, it may not need any modification at all, except for swapping out the potentiometer and replacing it with the KY-024 sensor.  I have the sensor ordered and will find out in a few days.  Thanks for your reply.


   
ReplyQuote
AV8R-Guy
(@av8r-guy)
Member
Joined: 2 years ago
Posts: 8
Topic starter  

@will , I have seen this video, and it does not accomplish what I’m after.  I have seen “tons” of Arduino Hall effect sensor videos, and so far none of them address the proximity of the magnet to the sensor with 10 (or however many) LEDs.

I did watch one YT video where the varying analog voltage (of the moving magnet) was displayed on a single LED that was dimmer or brighter, depending on how far the magnet is away from the sensor.  I can’t find that video, darn it.

I think that video would be the easiest to modify and get what I want.  Rather than have just one display LED varying the brightness, I could replace it with a LM3914 10 LED driver. 


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2506
 

@av8r-guy 

Oh, so you intend to use a single magnet and sensor ?

I didn't think the sensors had that much range. 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2506
 

@av8r-guy 

Is this the video ?

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1628
 

Hi @av8r-guy, You say

except for swapping out the potentiometer and replacing it with the KY-024 sensor

A potentiometer (in-circuit) typically produces a voltage that is related to the position of its wiper. Its connection to an Arduino would be a single analogue pin.

A quick Google shows that the KY-024 can produce a linear output, thus giving an indication of the strength of magnetic field, which maybe useful in certain situations, but you also talk of a linear system and "as it passes by a KY-024 Hall Effect sensor", suggesting a row of (say) 10 sensors and the UNO determines which one it is closest to. This requires a number of sensors and each will need to be connected to the UNO.

So how a simple 'swap' of a multiple KY-024s and a potentiometer is achieved is unclear.

I think it would be helpful if you clarified, possibly with a diagram or two, your precise intentions.

Best wishes, Dave

 


   
ReplyQuote
AV8R-Guy
(@av8r-guy)
Member
Joined: 2 years ago
Posts: 8
Topic starter  

@will, no, the one I was referring to had an Arduino in it.  Thanks.


   
ReplyQuote
AV8R-Guy
(@av8r-guy)
Member
Joined: 2 years ago
Posts: 8
Topic starter  

@davee, The 10 LEDs can be lit one at a time by one sensor.  The analog sensor (SS49e) (or the KY-024 using the analog out AO pin) sends a varying voltage to the Arduino.  The variance is due to a magnet’s proximity to the sensor.  On one video that I can’t seem to find, the Arduino showed a single LED becoming brighter or duller, depending on its distance from the sensor.

The Arduino receives such analog input and sends it out to an LED.  I believe it should be able to replace that single LED with an LM3914 10 LED driver, which will differentiate the voltage and light up the corresponding LED.  Do you still need a picture? 


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1628
 

Hi @av8r-guy,

Your explanation, centring around:

The variance is due to a magnet’s proximity to the sensor.

clears up the confusion on my part.

I recommend you confirm that the sensor can detect the magnet over the distance you expect before worrying about LED display side.

If it were my project, I would start by prototyping part of the system .. namely Arduino + sensor (and a magnet), and write/find some code which reads the sensor and continuously prints the output to the serial terminal.

Then run the program, whilst moving the magnet around the sensor, whilst watching the output values to get a feel for the relationship between the distance and the reading.

If you get sensible readings, then you can extend your project to drive LED display, controlled by the values returned by the sensor.

Best wishes and good luck! Dave

 


   
ReplyQuote
AV8R-Guy
(@av8r-guy)
Member
Joined: 2 years ago
Posts: 8
Topic starter  

@davee, there is a YT video that does exactly what you say (using the Arduino).  I lost it.  I will try to find it again.  Best regards.

if I can’t find it I will do what you suggest, sort of start from scratch.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2506
 

@av8r-guy 

Are you thinking of just lighting a single LED at a time, or pairing up when the magnet is in between LED proximity values ?

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2506
 
Posted by: @av8r-guy

@will, no, the one I was referring to had an Arduino in it.  Thanks.

Another try with schematic, PCB layout and sketch...

 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
AV8R-Guy
(@av8r-guy)
Member
Joined: 2 years ago
Posts: 8
Topic starter  

@will, EUREKA!!!!  You nailed it!!  That is exactly what I was looking for.  Now to round up the parts and make it.  


   
Peter Elsler reacted
ReplyQuote
Page 1 / 2