Unlimited rotation sensor

Hi, Im doing a project where i need to have something turned on as long as something is rotating. The point is to make people able to turn a "handle" and as long as it is rotating, something can happen. So im looking for a way to detect if there is rotation. Im new to this so i haven't been able to find what i need.

Basically my thoughts is:

if (x = turning){
Y = true;
}else{
Y = false;
}

Any idea how to achieve this? :slight_smile:

Try something like this.
Leo..

boolean sensorValue, previousValue, someThing;
unsigned long marker; // holds/marks the time the sensor changes

void loop() {
  sensorValue = digitalRead(sensorPin); // read sensor
  if (sensorValue != previousValue) { // if it has changed
    marker = millis(); // mark the time
    previousValue = sensorValue; // update
  }
  if (millis() - marker < 3000) { // if less than 3seconds
    someThing = true;
  } else someThing = false;
}

Hi,

Just use some sensor that notices that a point or points on the handle or shaft "goes by".

Possibilities are "optointerrupter" modules that notice when something (like a little 'flag' on the shaft) interrupts their light beam.

And magnetic "Hall Effect" sensors that notice a little magnet (maybe taped or glued on the handle) as it goes by.

Can you use something like that??

Yeah that would be an option. But im looking for something that instantly detects if the handle is spinning. Kinda like a fishing reel. The second you stop reeling, the line stops. Hope it makes sense :slight_smile:

could something like this be used? Cjmcu-103 rotation angle sensor module sv01a103aea01r00 trimmer 10k potentiometer analog voltage output Sale - Banggood.com-arrival notice-arrival notice

That sensor works with a potentiometer, which has a maximum rotation angle of 270degrees.

Google "rotary encoder", for sensors that can continuously rotate.

The code I posted has a timeout of three seconds. That can ofcourse be made shorter.
Leo..

Rotary encoders can see movement quicker but all require a certain minimum amount of motion before it can be detected. Or a minimum speed, for that matter.
A rotary encoder (slotted optical discs) may have 10 slots, so 20 dark/light changes. That means up to 360/20 = 18 degrees of rotation before you see it change. When moving, the next tick of the sensor comes as the encoder moved another 18 degrees.
Some encoders have higher resolution, but still the same problem. There is no such thing as "as soon as there is motion", it always has to be "... of a certain speed and a certain minimal rotation", where the same of course accounts for sensing the cessation of the motion.