![]() Long total112 = cs_2_12.capacitiveSensor(sensor) #define replay 40 //define debouncing, high value will increase stability while increasing response timeĬapacitiveSensor cs_2_12 = CapacitiveSensor(2,12) // 2.2M resistor between pins 2 & 12, pin 2 is send pin, pin 12 is sensor pinĬapacitiveSensor cs_2_11 = CapacitiveSensor(2,11) // 2.2M resistor between pins 2 & 11, pin 2 is send pin, pin 11 is sensor pinĬapacitiveSensor cs_2_10 = CapacitiveSensor(2,10) // 2.2M resistor between pins 2 & 10, pin 2 is send pin, pin 10 is sensor pinĬapacitiveSensor cs_2_9 = CapacitiveSensor(2,9) ĬapacitiveSensor cs_2_8 = CapacitiveSensor(2,8) ĬapacitiveSensor cs_2_7 = CapacitiveSensor(2,7) ĬapacitiveSensor cs_2_6 = CapacitiveSensor(2,6) ĬapacitiveSensor cs_2_5 = CapacitiveSensor(2,5) ĬapacitiveSensor cs_2_4 = CapacitiveSensor(2,4) ĬapacitiveSensor cs_2_3 = CapacitiveSensor(2,3) Ĭs_2_12.set_CS_AutocaL_Millis(0xFFFFFFFF) //Calibrate the sensor.Ĭs_2_11.set_CS_AutocaL_Millis(0xFFFFFFFF) Ĭs_2_10.set_CS_AutocaL_Millis(0xFFFFFFFF) Ĭs_2_9.set_CS_AutocaL_Millis(0xFFFFFFFF) Ĭs_2_8.set_CS_AutocaL_Millis(0xFFFFFFFF) Ĭs_2_7.set_CS_AutocaL_Millis(0xFFFFFFFF) Ĭs_2_6.set_CS_AutocaL_Millis(0xFFFFFFFF) Ĭs_2_5.set_CS_AutocaL_Millis(0xFFFFFFFF) Ĭs_2_4.set_CS_AutocaL_Millis(0xFFFFFFFF) Ĭs_2_3.set_CS_AutocaL_Millis(0xFFFFFFFF) #define sensor 1 //define number of samples Arduino takes, high value will increase stability while increasing response time #define total 30 //define sensitivity, high value for decreases sensitivity, low value increases MyPort = new Serial(this, portName, 115200) String portName = "/dev/cu.usbmodem1411" //Change COM48 to the port number that your Arduino is connected, you can check the port number from arduino program. String val // Data received from the serial port Serial myPort // Create object from Serial class I've posted the schematic and code for Arduino and Processing below. I want it to start detecting my finger from at least a few inches away. Even after using a 10M ohm resistor, my program is only responding when I'm touching the electrodes. I went according to my design and tried it out. “you_suffer.mp3”).I've made use of the cap sense library in Arduino to make a touch less piano. To play the audio file you have now placed in your Processing folder, simply plug it in to the code provided by the link by deleting the song title they have in quotes (“mysong.wav”), and typing in the file name of your audio file between the quotes (e.g. If you wish to play a different audio file, this link provides you with code to do so, as well as lots of helpful info about Minim. If you do use this file, re-title it “you_suffer.mp3”, place it in your Processing folder, and use the code I provide below. It’s amazing, and downloadable here if you want to use my code. We chose a Napalm Death song titled “You Suffer”, which lasts about 3 seconds. Place your audio file in the Processing folder that you just generated. ![]() Next, select an audio file, something short. This folder will have the same title as your processing file. When you save, a folder will be generated to contain your Processing file. Save it under your file name of choice (I called mine “Minim_1”). The only assembly required to run this function is to connect your arduino to a computer via usb. It can also be used outside of Processing, but we’re not going to get into that here. Minim comes included with Processing software. Processing is capable of performing these magical feats of musical playback by virtue of the Minim library. Virtually all contemporary music is formatted in stereo, and it is the format we are accustomed to listening to. To clarify this terminology, “mono” means the audio file has a single audio channel, as opposed to the left and right audio channels of stereo audio files. While it is possible to use arduino to play individual audio files in mono, Processing allows for the playback of audio files in stereo, and can overlap multiple audio files at once. In this larger project, the function we describe here will be linked with the function of using a piezo sensor to detect vibration. We intend to use this function as part of a larger project involving the use of sensors in public spaces to trigger pre-recorded sounds when people pass through the space. ![]() ![]() In this tutorial, we will demonstrate how to use Processing to play an audio file of your choise. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |