Replacing the speaker circuit |
- Connect the positive foot speakers on pin 9 board arduino
- Connect the negative leg at GND on board arduino
- The next time the resulting sound is too loud, then you can add a resistor 100-1 k ohm on a positive or negative leg speaker. To that end, the use of project board will allow you to connect the resistor.
Make Tone
If we go back to the opening notes in this section, then to make the sound / tone 440 Hz we have to switch off 440 times with a delay of 1136 microseconds respectively. Note, its unit is microsecond (1/1000 milliseconds). Whereas delay function () which we use before the units in milliseconds. Therefore, to make the delay with unit microsecond we can use delayMicroseconds function ().
// Free Tutorial Arduino // www.ioisalman.com // Speaker is on pin 9 const int pinSpeaker = 9; // Delay for 440 Hz tone const int timeDelay = 1163; void setup () { pinMode (pinSpeaker, OUTPUT); } void loop () { digitalWrite (pinSpeaker, HIGH); delayMicroseconds (timeDelay); digitalWrite (pinSpeaker, LOW); delayMicroseconds (timeDelay); }
When Sketch above program is executed, then the speaker will sound continuously until the speaker cable is disconnected or turned off the Arduino. That's how the speaker reads and make the program simple sound. Feel free to experiment with more frequency in order to better understand.
0 Response to "Replacing circuit Speaker and Make tone in arduino"
Post a Comment