Vibration motor control

Hello, I am trying to control a vibration motor in two sequence which I conveniently did using delay() function. but definitely not usable in the main project. can anyone help?

Your topic was MOVED to its current forum category as it is more suitable than the original because it is not an Introductory Tutorial

If the use of delay() is causing problems because it block program execution then see Using millis() for timing. A beginners guide, Several things at the same time and the BlinkWithoutDelay example in the IDE

Care to explain why?

i am using the motor for a status alert before posting SOS request to a server and will need to interrupt posting to with a debounce switch if the status detection is accidental.

delay stops other activities on the controller from running so i tried using millis() but not getting it right.

Thats probably down to your code (That we cannot see).

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Not quite sure what to make of that, but I do worry when people use the word "interrupt" because they frequently mistake the "interrupt" functionality of the microcontroller for something that they might be able to use to alter the primary behaviour.

The point is that your code - when you understand the use of millis() - needs to check for the limit switch within the loop() to determine when and how to take evasive action.

Debouncing of a switch is only necessary if you need to read it again for some reason soon after the first contact.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.