Replacing circuit Speaker and Make tone in arduino

Replacing the speaker circuit

Replacing the speaker circuit

                  Make a circuit As above with speaker 8 ohm or 16 ohm. The new speaker or speakers former radio still functions you can use. You can use a project board or not.



  1. Connect the positive foot speakers on pin 9 board arduino
  2. Connect the negative leg at GND on board arduino
  3. 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.

Subscribe to receive free email updates:

0 Response to "Replacing circuit Speaker and Make tone in arduino"

Post a Comment