Arduino UNO with a digital hall effect switch to control relay question

Discussion in 'Embedded Systems and Microcontrollers' started by John4ll4, Apr 9, 2016.

  1. John4ll4

    Thread Starter New Member

    Apr 9, 2016
    4
    0
    I have an Arduino UNO set up with a potentiometer to adjust the amount of time(up to 10 seconds at present) a relay closes a pair of contacts when a magnet slides by a hall effect switch. The problem the setup is having is when the magnet is stationary over the hall effect switch, then the relay contacts stay closed until the magnet is moved away. I need the relay to stay on for the set time and then turn off until the magnet passes by again. Is it possible to program this function into the UNO and if so, would someone point me to a tutorial to help me figure this out. This is my first project with a microcontroller and programming anything other then a VCR. I have searched the forums for similar issues without any success. Sure would appreciate any advice you can give me. Thanks, John
     
  2. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,388
    497
    Are you turning relay on and off with Uno?
     
  3. John4ll4

    Thread Starter New Member

    Apr 9, 2016
    4
    0
    At the moment I am turning on an led simulating the relay module, but the final project will replace the led with the relay.
     
  4. BR-549

    Well-Known Member

    Sep 22, 2013
    1,984
    388
    It's gonna depend on your hall switch output and your control strategy.

    "magnet slides by a hall effect switch" Is it a switch or sensor?

    Do you need to know the position of magnet, or just if it's moving or not?

    For position, you will need to compare magnitude of flux with a reference.

    For movement, compare magnitude with itself over short time.
     
  5. John4ll4

    Thread Starter New Member

    Apr 9, 2016
    4
    0
    It is a switch that outputs low when the magnet is moved across its face. If the magnet stops on the switch it will output low until the magnet
    moves away. That is where the problem resides. If the magnet stops on the switch I need the arduino to read the low once and then ignore the continuous low until the magnet moves away from the switch and the cycle repeats. I am guessing that the sketch will need to run an interrupt to monitor this low condition, but I haven't been able to grasp just how to do this. I appreciate any help you can offer to get me moving in the right direction.
     
  6. John4ll4

    Thread Starter New Member

    Apr 9, 2016
    4
    0
    I just figured it out using StateChange Detection. It is working well now. Thank you for leading me in the right path. Now it's onto adding more functionality to the project.
     
Loading...