In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge about the method of Python's self-made small musical instrument. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
The physical product is shown in the following picture:
The main purpose of this small instrument is to rely on adjustable resistors to adjust the input voltage, and then produce different tones of music through the buzzer. The blue cylindrical LED light inside is mainly used to show the current input voltage (but not). The brighter the LED light, the higher the tone of the buzzer output. Use the brightness and degrees of the board LED lamp to display the current frequency.
The process of making small musical instruments:
The main devices used in this simple instrument are as follows:
TurnipBit together
A buzzer (TurnipBit has its own headphone port, no buzzer connected to headphones and stereo, maybe it works better)
An adjustable resistor
Four DuPont lines
A crocodile clamp wire
LED one (may not be necessary)
A bread board (you can also use thread to connect the pins directly, it looks better with the bread board)
1. Brief introduction of buzzer
Buzzer is a kind of electronic buzzer with integrated structure, which is powered by DC voltage. It is widely used as audible devices in computers, printers, photocopiers, alarms, electronic toys, automotive electronic equipment, telephones, timers and other electronic products. Buzzer is mainly divided into two types: piezoelectric buzzer and electromagnetic buzzer. The buzzer is indicated by the letter "H" or "HA" in the circuit (the old standard is "FM", "ZZG", "LB", "JD", etc.).
two。 Brief introduction of adjustable resistor
The nominal value of the adjustable resistance is that the standard can be adjusted to the maximum resistance value. in theory, the resistance value of the adjustable resistance can be adjusted to any value within 0 and the nominal value, but because of the actual structure and design precision requirements and other reasons, it is often not easy to 100% to achieve "arbitrary" requirements, but "basically" to adjust within the allowable range, so as to change the resistance value.
The adjustable resistor has a total of three pins, the two pins are connected to 3.3V and GND respectively, and the middle pin is connected to the pin that wants to read the voltage value.
The hardware wiring method is as follows:
This time is mainly to use graphics coding to make a small experiment, this time the main commands to be used are the playing tone command in the music, the if and judgment condition command in the logic, the repeated command in the loop and the command to read the ADC value.
Next, we will introduce and explain the selection of these commands and the use of parameters in these commands.
1. Play tone command
The play tone command is to control the buzzer to play the corresponding tone.
Let's explain the parameters and how to use them.
When using this command, in the command selection area, select music and select the play tone command, as shown in the figure
The playback tone command has two parameters, which control the tone and time of the buzzer output, as shown below:
two。 If and judge the conditional command
If the judgment conditional command is used, the if command is used to determine whether the conditional command in the command is valid, and if so, the corresponding command is executed.
To use the if and judge condition command, you need to select logic in the command selection area, and select the if and judge condition command, as shown in the following figure:
When you select an if command, you must add a judgment condition command, as shown in the following figure:
3. Repeat command
Repeating a command is to determine whether a condition is true, and if the condition is true, execute the corresponding instruction.
Using the repeat command, select the loop in the command selection area, and select the repeat command, as shown in the following figure:
After selecting the repeated command, add a real command in the logic to the judgment condition to complete an infinite loop, as shown in the following figure:
4. Read ADC value
The command to read the ADC value is to read the voltage input of the corresponding pin.
To select the command to read the ADC value, you need to select the pin in the command selection area, and select to read the analog voltage of the X pin, as shown in the following figure:
The above introduces the use of the basic commands, and the following is the basic principle of a small musical instrument to be made this time.
The control end of this small instrument is an adjustable resistor connected to the power supply, which changes the corresponding output tone by changing the resistance value. Post a screenshot of the code I did below:
These are all the contents of the article "what is the method of making small musical instruments by Python?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.