-
• #2
You can use setTimeout:
read_heading(); setTimeout(send_vibration, 300); // No brackets() after send_vibration!
-
• #3
Best is maybe to use a
promise
. You could probably do withsetTimeout
as well.rigrig beat me to it!
-
• #4
Okay, yeah, setTimeout sounds good ! How can I make it so that the reading only happen once every X seconds, too ? Wouldn't setTimeout make it run in loop and do the reading of the loop X seconds back ?
-
• #5
setInterval
I'm trying to make a compass that tells the user it's heading through vibration patterns ( one for each cardinal direction ). Thing is, I need to make the reading THEN send the vibration pattern some time after, because the magnetometer goes crazy when trying to read while the vibrator is on.
So, how can I make it so that it does something like "read heading, wait 0.3s then send vibration" ?