Week4

This week is the last week of the entire project, and the main functions of our project will be completed this week.



All tasks include the following:

1. Complete the guitar part code.

2. Use switches to control transitions between instruments.

3. Use ultrasonic sensors to control changes in pitch.

4. Complete the poster production.



First, we complete the adjustment of the ultrasonic sensor. By changing the distance, the changes in the piano's tone can be controlled.






Secondly, the code for the guitar instrument is also completed this week. Changes in chords can also be controlled by changing the distance of the ultrasonic sensor.







Then we adjusted the circuit again. Add switches to control switching between instruments.







Final version of code


Python part

Mainly used serial and pygame libraries. The core approach of the code snippet is to receive the signal sent by Arduino through serial communication and play the corresponding audio file based on the content of the signal. Audio files are divided into piano, guitar, chords and accompaniment. Functions implemented include: audio file loading, audio playback control, dynamic audio management, and serial communication.







The core approach of the Arduino code is to detect user interactions through various sensors and send the detected actions to the connected computer through the serial port, allowing the Python code to play corresponding music based on the data. The functions implemented include: distance detection, string detection, mode switching, and data transmission. Together, these two pieces of code implement a system that allows music playback to be controlled through physical interaction.






At this point our projects are all completed.






Comments

Popular posts from this blog

Week1