giuliomoro
Thank you for teaching me. This patch is my goal. I could not have accomplished without you.
quwrof

- Sep 7, 2024
- Joined Jul 11, 2024
- 2 discussions
- 9 posts
giuliomoro
This is because, after considering versatile hardware, microcontrollers that run on c++ are also candidates for use.- Edited
M5Stack basic, bela trill craft, e-textile, ArduinolDE I wanted to use these to create a conductive cloth touch sensor that would respond to touch at three different locations and play a different sound each time, so I wrote the following program in C++.
However, because the conductive fabric is too large, it becomes like a proximity sensor as well as a touch sensor, making it impossible to determine the location of the three touches. When this kind of problem occurs with capacitive touch sensors, it is usual to change the threshold value, but since the touch values are extremely discriminated, adjusting the threshold value cannot solve the problem. And now I wanted to adjust the prescaler, but I don't know how to do it. Can anyone please advise me how to do this?void loop() { giBattery = M5.Power.getBatteryLevel(); M5.Lcd.setCursor(0, 0); M5.Lcd.printf("%3d \%",giBattery); M5.Lcd.printf("%%"); // Trill Craftからデータを要求 Wire.beginTransmission(TRILL_I2C_ADDRESS); Wire.write(0x04); // ペイロードを読むコマンド Wire.endTransmission(); Wire.requestFrom(TRILL_I2C_ADDRESS, 60); // データを要求 if (Wire.available() >= 4) { // 必要なデータの長さが4バイト以上であることを確認 uint8_t buffer[4]; Wire.readBytes(buffer, 4); // 最初の4バイトを読み取る int touchPosition = buffer[0]; // 最初のバイトをタッチ位置として読み取る int touchValue = buffer[1]; // 2番目のバイトをタッチ値として読み取る Serial.print("Touch Position: "); Serial.print(touchPosition); Serial.print(", Touch Value: "); Serial.println(touchValue); // センサー値をシリアルプロッタに表示 if (touchPosition != currentTouchPosition) { currentTouchPosition = touchPosition; // タッチ位置をM5Stackに表示 M5.Lcd.fillScreen(BLACK); //M5.Lcd.setTextColor(); M5.Lcd.setCursor(0, 80); M5.Lcd.printf("Position: %d\n", currentTouchPosition); M5.Lcd.printf("Value: %d\n", touchValue); byte data; Serial.printf("Touch Position: %d\n", currentTouchPosition); // タッチ位置に基づいて異なるMP3ファイルを再生 if(touchValue > 127){ switch (currentTouchPosition) { case 0: Serial.println("Playing piano_c4_2.mp3"); playMP3("/piano_c4_2.mp3"); break; case 3: Serial.println("Playing piano_d4_2.mp3"); playMP3("/piano_d4_2.mp3"); break; case 6: Serial.println("Playing piano_e4_2.mp3"); playMP3("/piano_e4_2.mp3"); break; default: // タッチ位置が0, 3, 6以外の場合、再生を停止 Serial.println("Touch position not recognized. No action taken."); break; } } } } giBatteryOld = giBattery; delay(100); // センサーへの過度な負荷を避けるための小さな遅延 }
I am now looking like the attached photo based on what you have told me. If I disconnect [route 1 0] and the second connection [playAudioFile~] the wav file plays to the end but loops forever, if I disconnect the second connection no other sounds are played for 7 seconds but the wav file only plays for as long as the threshold is exceeded.
max
Thank you for your prompt reply. I followed your instructions and was able to play the wav file all the way through. Thank you very much. However, my goal is to not get the value of the touch in trill craft until the wav file is done playing and not to play the same wav file sound. With the improved patch, if I touch the sensor again while the wav file is playing, the sound of the wav file will sound over the wav file. Is there any remedy for this?- Edited
Hi, I am from Japan and interested in bela and trill craft. I would like to sound a wav file in trill craft using the pure data example. I just have one change I would like to make. That is that I want the wav file to play until the end once it crosses the threshold. In the example, the wav file will only play when the threshold is exceeded. I have seen other people's questions, but I am not sure what to change in pure data and how to do it. I would appreciate it if you could help me. I am attaching my current patch for my pure data. Could you please check it for me.
Sorry if my english is wrong.