0% found this document useful (0 votes)
90 views

Arduino and Speaker Example PDF

This document provides instructions for connecting a speaker to an Arduino board to play tones. The schematic shows connecting the speaker to pin 8 on the Arduino through a 100 ohm resistor. The code plays the Morse code for SOS by generating tones for dots and dashes with delays in between. It repeats the SOS pattern and then waits 3 seconds before repeating.

Uploaded by

realaffiliate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views

Arduino and Speaker Example PDF

This document provides instructions for connecting a speaker to an Arduino board to play tones. The schematic shows connecting the speaker to pin 8 on the Arduino through a 100 ohm resistor. The code plays the Morse code for SOS by generating tones for dots and dashes with delays in between. It repeats the SOS pattern and then waits 3 seconds before repeating.

Uploaded by

realaffiliate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Arduino and speaker example

Another simple example is to hook up a speaker to your Arduino.

Schematic

arduino speaker schematic


Layout

arduino speaker

Code
A simple example.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

int pin = 8;
int note = 988;
void setup()
{
}
void loop()
{
//3 dots for the S
for (int i=0; i<3; i++)
{
tone(pin, note, 100);
delay(200);
noTone(pin);
}
delay(200);
//3 dashes for the O
for (int i=0; i<3; i++)
{
tone(pin, note, 300);
delay(400);
noTone(pin);
}
delay(200);
//3 dots for the S again
for (int i=0; i<3; i++)
{
tone(pin, note, 100);
delay(200);

31
32
33
34
35
36

noTone(pin);
}
delay(200);
//wait 3 seconds
delay(3000);
}

Parts List

Amount
1
1
1

Part Type
Arduino Uno (Rev3)
100 Resistor
Loudspeaker

You might also like