![]() The best way is to include a “calibration” mode, which is something I’ve done. I only read one analog port at a time as the reading itself takes a bit of processing time, so I share it out in between processing the other sensors expiry.Īll well and good so far, but how do you choose the thresholds for triggering and expiry times? That will depend on your sensor, how its mounted, how hard it can be hit, and how much flexibility of movement in the sensor afterwards. ![]() I also use the expiry of the “excluded” time to trigger a MIDI note off. This means that timer will eventually wrap around back to zero after 50 years or so, so for these purposes it works fine. The millis() call returns an unsigned long, that is a number between 0 and 4,294,967,295. ![]() When it comes to checking the sensor, if the latest reading of the millisecond timer is still within the “excluded” time, I don’t try to read it again. When the sensor is triggered I read the current millisecond counter using millis() which returns the number of milliseconds since the Arduino was turned on. IF so, then record the current time in milliseconds Is the value over the THRESHOLD for triggering? IF the sensor was activated previously THENĮLSE IF the sensor is the one we're reading THEN My approach is largely as follows: For each time round the Arduino's loop: But to keep track of what is going on for several sensors at the same time gets a bit more fiddly. To do that for a single input is fairly easy – once triggered, just don’t read it again for a short while. The trick is to avoid re-triggering quickly as the signal from the sensor will bounce around a fair bit. The basic principle, as described in the Knock tutorial, is to read the analog port and when the value rises above a certain threshold, treat it as being “triggered”. The code to handle piezo sensors is relatively straight forward. If you want a proper drum sensor, have a look (and admire) Marco’s build. Neither things of which I’ve done in the above! The other projects I’ve listed really do this properly. ![]() In particular having a good interface between your sensor and the surface is important, as it reducing the direct force on the sensor itself. This kept things very simple, but isn’t very robust. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |