Project showcase
Brasileirinho tone

Brasileirinho tone © CC BY-NC

Arduino playing the Waldir Azevedo's musical theme "Brasileirinho" with the tone function and with a speaker.

  • 841 views
  • 2 comments
  • 2 respects

Components and supplies

About this project

I discovered Arduino two months ago and I'm exploring its musical applications. At this stage of learning I am using the tone function to play a two-part piece.

I made the musical arrangement in the Finale software, and then I made the MIDI file into Arduino code through http://greenlightgo.org/projects/midi-to-arduino/ Then I set up a very simple circuit with only one speaker on pin 4.

Code

Brasileirinho ToneArduino
To open the file with Arduino IDE.
/**
   Peça musical executada pela função Tone do Arduino. Execução monofônica. (Musical piece performed by Arduino Tone function. Monophonic playback.)
   Título(Title): Brasileirinho.
   Música (Music): Waldir Azevedo.
   Arranjo (Arrangement): Glauber Santiago.
   Circuito (Circuit): Autofalante de 8 ohm no pino 4 (8 ohm speaker on digital pin 8).
   MIDI-Arduino Sequencing code generator
   Courtesy of http://greenlightgo.org/projects/midi-to-arduino/
   A peça será executada uma vez apenas. Its will be executed once only.
 **/

#define msPerTick 0.4 //Andamento(Tempo)

void setup() {
  pinMode(4, OUTPUT);

  doPerformance();
}

void loop() {
}

void doPerformance() {
  tone(4, 494);

  delay(102 * msPerTick);

  noTone(4);

  delay(154 * msPerTick);

  tone(4, 494);

  delay(205 * msPerTick);

  noTone(4);

  delay(307 * msPerTick);

  tone(4, 494);

  delay(102 * msPerTick);

  noTone(4);

  delay(410 * msPerTick);

  tone(4, 392);

  delay(205 * msPerTick);

  noTone(4);

  delay(307 * msPerTick);

  tone(4, 494);

  delay(102 * msPerTick);

  noTone(4);

  delay(154 * msPerTick);

  tone(4, 587);

  delay(205 * msPerTick);

  noTone(4);

  delay(819 * msPerTick);

  tone(4, 294);

  delay(205 * msPerTick);

  noTone(4);

  delay(819 * msPerTick);

  tone(4, 147);

  delay(205 * msPerTick);

  noTone(4);

  delay(307 * msPerTick);

  tone(4, 988);

  delay(512 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(512 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(384 * msPerTick);

  tone(4, 196);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(128 * msPerTick);

  tone(4, 147);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(128 * msPerTick);

  tone(4, 196);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(128 * msPerTick);

  tone(4, 147);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 932);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 196);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 932);

  delay(128 * msPerTick);

  tone(4, 147);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 932);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(128 * msPerTick);

  tone(4, 196);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 932);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(128 * msPerTick);

  tone(4, 147);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 932);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 196);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(128 * msPerTick);

  tone(4, 147);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(128 * msPerTick);

  tone(4, 196);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(128 * msPerTick);

  tone(4, 294);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 932);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 880);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 831);

  delay(128 * msPerTick);

  tone(4, 392);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 233);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 247);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 294);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 233);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 247);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 294);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 233);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 247);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 294);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 233);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 247);

  delay(128 * msPerTick);

  tone(4, 147);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 294);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(128 * msPerTick);

  tone(4, 196);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(128 * msPerTick);

  tone(4, 185);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(128 * msPerTick);

  tone(4, 165);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(128 * msPerTick);

  tone(4, 147);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 932);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 196);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 932);

  delay(128 * msPerTick);

  tone(4, 175);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 932);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(128 * msPerTick);

  tone(4, 156);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 932);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(128 * msPerTick);

  tone(4, 147);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 932);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 196);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(128 * msPerTick);

  tone(4, 185);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(128 * msPerTick);

  tone(4, 165);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 988);

  delay(128 * msPerTick);

  tone(4, 147);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 988);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 932);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 880);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 831);

  delay(128 * msPerTick);

  tone(4, 98);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 247);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 247);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 247);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 247);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 233);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 220);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 208);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 196);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 185);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 165);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 147);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 98);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 659);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 698);

  delay(128 * msPerTick);

  tone(4, 294);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 740);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 698);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 659);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(128 * msPerTick);

  tone(4, 220);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 659);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 698);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 740);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 698);

  delay(128 * msPerTick);

  tone(4, 294);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 659);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 659);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 698);

  delay(128 * msPerTick);

  tone(4, 220);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 740);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 698);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 659);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(128 * msPerTick);

  tone(4, 294);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 740);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 659);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 587);

  delay(128 * msPerTick);

  tone(4, 196);

  delay(128 * msPerTick);

  noTone(4);
  noTone(4);
  tone(4, 784);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 740);

  delay(256 * msPerTick);

  noTone(4);
  tone(4, 659);

  delay(256 * msPerTick);
...

This file has been truncated, please download it to see its full contents.

Schematics

https://www.tinkercad.com circuit
Milldias sd6rllccfh

Comments

Similar projects you might like

A Tone Generator With LCD Display!

Project tutorial by cronenborg

  • 3,120 views
  • 0 comments
  • 8 respects

US National Anthem with Lights & Tone

Project tutorial by Ryan Aebi

  • 820 views
  • 2 comments
  • 6 respects

Generating Audio with an Arduino and a Resistor Ladder DAC

Project showcase by 3 developers

  • 3,995 views
  • 5 comments
  • 11 respects

Automatizing Percussion with Solenoids: "The Sound Compass"

Project tutorial by touchmysound

  • 4,123 views
  • 4 comments
  • 13 respects

Music Adaptive RGB LED with Arduino and Processing

Project in progress by ounane mohamed elfarouk

  • 2,953 views
  • 8 comments
  • 24 respects

Electronic Music

Project showcase by Glauber Santiago

  • 1,258 views
  • 1 comment
  • 0 respects
Add projectSign up / Login