MHeironimus / ArduinoJoystickLibrary

An Arduino library that adds one or more joysticks to the list of HID devices an Arduino Leonardo or Arduino Micro can support.
GNU Lesser General Public License v3.0
2.06k stars 403 forks source link

Request buttons #233

Closed JerryDaga closed 2 years ago

JerryDaga commented 2 years ago

Good day sir. I have requested a new code for all types of Arduino. Can you make it as "Piezo Sensor to Button Switch or Mapping"?

I want to make a D.I.Y. Table Top E-Drum like this (Attached Photo)

Scan - 2022-01-29 19_02_19.pdf

fbrinker commented 2 years ago

I am not sure if I understand your request correctly, but you should be able to map that signal to multiple buttons. Just connect the sensor to an analog input and use the arduino function https://www.arduino.cc/en/Reference/AnalogRead to get the sensors value.

Then you can simulate a button press via Joystick.pressButton(x) if the value is < 100. Another if the value is < 200, < 300, < 400... as an example. And depending on the sensors intensity another button is pressed. Or you can map all inputs above 0 to a single button.

I've never worked with a piezo sensor, so I can't recommend any code basics. You may find some help over in the Arduino forums :)

MHeironimus commented 2 years ago

This library does not focus on how to read values from input devices. It only focuses on making the Arduino appear to the host device as a game controller / joystick.