Using a hall effects sensot

I am trying to set up a thumper for a cranes winch response. It reads a halleffects sensor then sends a feed back to the control hanle using a megnetic thumper. I have a code that is working but my problem is when the sensor lands on a pin when stopped the thumper output stays high. I need this to resort to LOW when the signal is contant.

What would a "constant " signal look like?

The signal is a 5v constant input. When the winch motor is turning it is an interrupted input

post a schematic of your wiring?
post your code (using code tags </>)

int buttonState = 0;

int i = 0;

void setup()
{
pinMode(2, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(10, OUTPUT);
}

void loop()
{
// read the state of the pushbutton value
buttonState = digitalRead(2);
// check if pushbutton is pressed. if it is, the
// buttonState is HIGH
if (buttonState == HIGH) {
// turn LED on
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(10, HIGH);
delay(100); // Wait for 100 millisecond(s)
digitalWrite(10, LOW);
delay(50); // Wait for 50 millisecond(s)
digitalRead(10, HIGH>= 500);
digitalWrite(10, LOW)

} else {
// turn LED off
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(10, LOW);
}
}

i cannot upload files being I'm a new user,sorry

Does it actually disappear or does it go to zero volts?

It goes to zero volts, when the sensor does not detect a pin on the chopper wheel, the problem is the pins are so close together that when you stop the winch 9 times out of 10 it stops on a pin that the sensor picks up and send a high(5v) back to the controller(arduino board). The code now turns that into an high/low output to activate the magnetic thumper( coil that chatters a pin in the winch control handle) it has to be high/low or it will burn the coul out rather quick

If I understand that correctly, the solution is to put the "thumper" code in a function and limit the time that function is called to some number of seconds. Does that seem like a solution?

Yes it does im thinking something like
If if pin 2 is high for more that 250 millis write to low and wait for a change of pin two state?
Kinda im reall new at this if you didnt notice.
I appreciate the help

your code (post #5) does not compile

sketch_nov04a:25:27: error: too many arguments to function 'int digitalRead(uint8_t)'
 digitalRead(10, HIGH>= 500);

digitalRead() takes a single parameter the pin being read

there is also a ; missing off the end of the next line

digitalWrite(10, LOW)

use code tags </> when posting code
what Arduino are you using?
post a schematic of the circuit?

int buttonState = 0;

unsigned long currentTime = millis();
const unsigned long eventInterval = 250;
unsigned long previousTime = 0;

void setup()
{
pinMode(2, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(10, OUTPUT);
unsigned long currentTime = millis();

if (digitalRead(2) >= eventInterval);
(currentTime - previousTime >= eventInterval);
/* Event code*/
digitalWrite(10, LOW);
/* Update the timing for the next time around */
previousTime = currentTime;

}

void loop()
{

// read the state of the pushbutton value
buttonState = digitalRead(2);
// check if pushbutton is pressed. if it is, the
// buttonState is HIGH
if (buttonState == HIGH) {
// turn LED on
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(10, HIGH);
delay(100); // Wait for 100 millisecond(s)
digitalWrite(10, LOW);
digitalWrite(LED_BUILTIN, LOW);
delay(50); // Wait for 50 millisecond(s)

}
else {
// turn LED off
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(10, LOW);
}
}

still cnnot write 10 to low after 250 millis. it just stays in the blinking pattern

remove the ; on the end of the if() statement - it will terminate the if()

im not sure, it didnt work all i need this to do is is if the input on pin 2 is high for more than 250 milliseconds it needs to set pin 10 to low until the state of pin 2 changes back to a pulse

try this - if the input on pin 2 is high for more than 2500 milliseconds it sets pin 10 to low until the state of pin 2 changes back to low and pin 10 is set high

int buttonState = 0;

unsigned long currentTime = millis();
const unsigned long eventInterval = 2500;
unsigned long previousTime = millis();

void setup()
{
  pinMode(2, INPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(10, OUTPUT);
}


void loop()
{
  // check if pushbutton is pressed. 
  if (digitalRead(2) == HIGH) {
    if (millis() - previousTime > eventInterval) {
      // turn LED on
      digitalWrite(LED_BUILTIN, HIGH);
      digitalWrite(10, LOW);
      while (digitalRead(2) == HIGH) ;    // loop until LOW
      digitalWrite(10, HIGH);
      digitalWrite(LED_BUILTIN, LOW);
      previousTime = millis();    }
  }
  else {
    // turn LED off
    digitalWrite(LED_BUILTIN, LOW);
    digitalWrite(10, HIGH);
    previousTime = millis();
  }
}

nope that isnt working,
is there a line of code that says if digital pin two reads high for longer than 250 millis
digital write pin two to low?

int buttonState = 0;

unsigned long currentTime = millis();
const unsigned long eventInterval = 600;
unsigned long previousTime = millis();

void setup()
{
pinMode(2, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(10, OUTPUT);
}

void loop()
{
// check if pushbutton is pressed.
if (digitalRead(2) == HIGH) {
if (millis() - previousTime <= eventInterval) {
// turn LED on
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(10, LOW);
while (digitalRead(2) == HIGH) ; // loop until LOW
digitalWrite(10, HIGH);
delay(50);
digitalWrite(LED_BUILTIN, LOW);
previousTime = millis(); }
}
else {
// turn LED off
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(10, LOW);
previousTime = millis();
}
}

THIS WORKS,
thank you very much for the help with this!!!!!

Hi,
I know I've read this thread late.
Why aren't you looking for the sensor signal to go from LOW to HIGH to trigger your thumper, NOT when it is HIGH.
The transition can only happen when the wheel is moving, which is what you want.

Google;

Arduino detecting change of state

Tom... :smiley: :smiley: :+1: :coffee: :australia: