Arduino (IoT): Simple Tutorial Creando Melodías con Piezo Buzzer & Arduino Nano

Arduino Honduras Santiapps Marcio Valenzuela

Tutorial Fet, iOS & Bluno Nano

En este tutorial aprenderemos sobre la Bluno Nano y su utilidad para controlar remotamente un proyecto.

Requisitos:

  1. Computadora (mac)
  2. Arduino nano
  3. Breadboard, 1kR & Piezo Buzzer
  4. Arduino IDE (https://www.arduino.cc/en/Main/Software)

La conexión es del pin 3 de la Nano al + del buzzer.  El GND de la Nano va a tierra del buzzer a traves de un 1kR.

El código en este caso es muy sencillo:

#include "pitches.h"
int melody[] = {
  NOTE_B4, NOTE_E5, 0, NOTE_E5, 0, NOTE_E5, NOTE_E5, 0, NOTE_DS5, 0, NOTE_CS5, NOTE_CS5, 0,
  NOTE_B4, NOTE_DS5, 0, NOTE_DS5, 0, NOTE_DS5, NOTE_DS5, 0, NOTE_CS5, 0, NOTE_B4, NOTE_B4, 0,
  NOTE_GS4, NOTE_CS4, 0, NOTE_CS4, 0, NOTE_CS4, NOTE_CS4, 0, NOTE_B4, 0, NOTE_A4, NOTE_A4, 0,
  NOTE_FS4, NOTE_B4, 0, NOTE_B4, 0, NOTE_B4, NOTE_B4, 0, NOTE_AS4, 0, NOTE_GS4, NOTE_GS4, 0,
  NOTE_E4, NOTE_A4, 0, NOTE_A4, 0, NOTE_A4, NOTE_A4, 0, NOTE_G4, 0, NOTE_F4, NOTE_F4, 0,
  NOTE_D4, NOTE_G4, 0, NOTE_G4, 0, NOTE_G4, NOTE_G4, 0, NOTE_F4, 0, NOTE_DS4, NOTE_DS4, 0,
  NOTE_GS4, 0, NOTE_E4, 0, NOTE_GS4, NOTE_GS4, NOTE_B4, NOTE_A4, NOTE_GS4, NOTE_FS4
};

int noteDurations[] = {
  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 8, 4,
  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 8, 4,
  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 8, 4,
  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 8, 4,
  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 8, 4,
  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 8, 4,
  4, 4, 4, 4, 4, 4, 8, 4, 8, 8
};

void setup() {
  for (int thisNote = 0; thisNote < 88; thisNote++) {
    int noteDuration = 1000 / noteDurations[thisNote];
    tone(3, melody[thisNote], noteDuration);
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    noTone(3);
  }
}

void loop() {
  // ...
}

El proyecto final es así:

Proyecto Final

Leave a Reply