Christmas Bell That SINGS!

by Arnov Sharma in Circuits > Audio

1227 Views, 5 Favorites, 0 Comments

Christmas Bell That SINGS!

PCB Christmas Bell Project
15 (9).gif
0001.jpg

Hey guys welcome back.

So here's a project with a Christmas theme that resembles Jingle Bells and plays three Christmas songs when you hit three buttons.

The heart of this project is Seeed Studio's XIAO Samd21 Dev board and a custom bell-shaped PCB all ordered from Seeed Studio's site.

A basic sketch that comprises three predefined melodies that are played when Button A, Button B, or Button C is pressed is used in this project, which uses the Arduino's Pitches library to play several tunes.

Regarding the PCB design, the XIAO microcontroller was the main unit, and the PCB shape was modified to resemble a Christmas bell.

This Instructables is about the whole built process, so let's get started.

Supplies

following are the things used in this project-

  • Custom PCB
  • XIAO SAMD21 MCU
  • Buzzer
  • SMD Buttons
  • 1k 0805 Resistor
  • Blue LED 0805 Package
  • Header Pins
  • Breadboard
  • THT LED
  • THT Switch

Concept-Original Project

christmas-arduino_E7UIZMG6NF.jpg

This project, as mentioned, is based on Joshi's Piezo Christmas Song Project, which you can check out at the link below.

https://www.hackster.io/joshi/piezo-christmas-songs-fd1ae9

The original project was a simple tutorial that showed how to utilize the Pitches library with an AVR MCU, like the Arduino Uno, to play tunes.

I used an XIAO MCU and a custom PCB to create my own version of the circuit after making a few significant changes to the sketch.

XIAO SAMD21

03 (9).gif

In this project, I'm using Seeed's XIAO SAMD21 Dev Board, which is based on an ARM® Cortex®-M0+(SAMD21G18) running at up to 48Hz instead of Arduino Uno. Along with the potent CPU, it also includes 256KB Flash and 32KB SRAM, both of which are quite helpful for driving displays.

Its compact size makes it one of the easiest Arduino-compatible boards to integrate into the circuitry.

Breadboard Edition

1Capture.JPG
05 (11).gif
04 (10).gif

In order to test the code, we first prepare a basic breadboard version of the circuit.

  • Three buttons are connected to GPIO 8, GPIO 9, and GPIO 10, while each button's other end is connected to the board's GND port.
  • Additionally, GPIO7, GND, and an LED are added.
  • We connect a Buzzer to GPIO 0 and GND for audio output.

Three melodies may be changed by pressing any button, and during playback, a led blinks for each tone played. We uploaded the basic sketch to the XIAO Board, and it immediately began to work.

CODE

#include "pitches.h"
int melodyPin = 0;
int D7 = 7;
int D8 = 8;
int D9 = 9;
int D10 = 10;


//#define melodyPin = D0

// Jingle Bells

int melody[] = {
NOTE_E5, NOTE_E5, NOTE_E5,
NOTE_E5, NOTE_E5, NOTE_E5,
NOTE_E5, NOTE_G5, NOTE_C5, NOTE_D5,
NOTE_E5,
NOTE_F5, NOTE_F5, NOTE_F5, NOTE_F5,
NOTE_F5, NOTE_E5, NOTE_E5, NOTE_E5, NOTE_E5,
NOTE_E5, NOTE_D5, NOTE_D5, NOTE_E5,
NOTE_D5, NOTE_G5
};

int tempo[] = {
8, 8, 4,
8, 8, 4,
8, 8, 8, 8,
2,
8, 8, 8, 8,
8, 8, 8, 16, 16,
8, 8, 8, 8,
4, 4
};

// We wish you a merry Christmas

int wish_melody[] = {
NOTE_B3,
NOTE_F4, NOTE_F4, NOTE_G4, NOTE_F4, NOTE_E4,
NOTE_D4, NOTE_D4, NOTE_D4,
NOTE_G4, NOTE_G4, NOTE_A4, NOTE_G4, NOTE_F4,
NOTE_E4, NOTE_E4, NOTE_E4,
NOTE_A4, NOTE_A4, NOTE_B4, NOTE_A4, NOTE_G4,
NOTE_F4, NOTE_D4, NOTE_B3, NOTE_B3,
NOTE_D4, NOTE_G4, NOTE_E4,
NOTE_F4
};

int wish_tempo[] = {
4,
4, 8, 8, 8, 8,
4, 4, 4,
4, 8, 8, 8, 8,
4, 4, 4,
4, 8, 8, 8, 8,
4, 4, 8, 8,
4, 4, 4,
2
};

// Santa Claus is coming to town

int santa_melody[] = {
NOTE_G4,
NOTE_E4, NOTE_F4, NOTE_G4, NOTE_G4, NOTE_G4,
NOTE_A4, NOTE_B4, NOTE_C5, NOTE_C5, NOTE_C5,
NOTE_E4, NOTE_F4, NOTE_G4, NOTE_G4, NOTE_G4,
NOTE_A4, NOTE_G4, NOTE_F4, NOTE_F4,
NOTE_E4, NOTE_G4, NOTE_C4, NOTE_E4,
NOTE_D4, NOTE_F4, NOTE_B3,
NOTE_C4
};

int santa_tempo[] = {
8,
8, 8, 4, 4, 4,
8, 8, 4, 4, 4,
8, 8, 4, 4, 4,
8, 8, 4, 2,
4, 4, 4, 4,
4, 2, 4,
1
};

int switchOne = 0;
int switchTwo = 0;
int switchThree = 0;

void setup(void) {
pinMode(0, OUTPUT); // Buzzer
pinMode(D7, OUTPUT); // Led indicator when singing a note
pinMode(D10, INPUT_PULLUP);
pinMode(D9, INPUT_PULLUP);
pinMode(D8, INPUT_PULLUP);
}

void loop() {
switchOne = digitalRead(D10);
switchTwo = digitalRead(D9);
switchThree = digitalRead(D8);
if (switchOne == LOW) {
sing(1);
} else if (switchTwo == LOW) {
sing(2);
} else if (switchThree == LOW) {
sing(3);
}
}

int song = 0;

void sing(int s) {
// iterate over the notes of the melody:
song = s;
if (song == 3) {
Serial.println(" 'We wish you a Merry Christmas'");
int size = sizeof(wish_melody) / sizeof(int);
for (int thisNote = 0; thisNote < size; thisNote++) {

// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000 / wish_tempo[thisNote];

buzz(melodyPin, wish_melody[thisNote], noteDuration);

// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);

// stop the tone playing:
buzz(melodyPin, 0, noteDuration);

}
} else if (song == 2) {
Serial.println(" 'Santa Claus is coming to town'");
int size = sizeof(santa_melody) / sizeof(int);
for (int thisNote = 0; thisNote < size; thisNote++) {

// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 900 / santa_tempo[thisNote];

buzz(melodyPin, santa_melody[thisNote], noteDuration);

// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);

// stop the tone playing:
buzz(melodyPin, 0, noteDuration);

}
} else {

Serial.println(" 'Jingle Bells'");
int size = sizeof(melody) / sizeof(int);
for (int thisNote = 0; thisNote < size; thisNote++) {

// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000 / tempo[thisNote];

buzz(melodyPin, melody[thisNote], noteDuration);

// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);

// stop the tone playing:
buzz(melodyPin, 0, noteDuration);

}
}
}

void buzz(int targetPin, long frequency, long length) {
digitalWrite(D7, HIGH);
long delayValue = 1000000 / frequency / 2; // calculate the delay value between transitions
//// 1 second's worth of microseconds, divided by the frequency, then split in half since
//// there are two phases to each cycle
long numCycles = frequency * length / 1000; // calculate the number of cycles for proper timing
//// multiply frequency, which is really cycles per second, by the number of seconds to
//// get the total number of cycles to produce
for (long i = 0; i < numCycles; i++) { // for the calculated length of time...
digitalWrite(targetPin, HIGH); // write the buzzer pin high to push out the diaphram
delayMicroseconds(delayValue); // wait for the calculated delay value
digitalWrite(targetPin, LOW); // write the buzzer pin low to pull back the diaphram
delayMicroseconds(delayValue); // wait again or the calculated delay value
}
digitalWrite(D7, LOW);

}


I've made a few adjustments to the code, among them making each button's output INPUT PULLUP so we can get rid of the external pullup resistors that were incorporated into the original idea.

PCB Design

2Capture.JPG
sch_page-0001.jpg
Capture3.JPG

In the PCB Editor, we add XIAO and connect three buttons to GPIO8, 9, and 10 as well as GND to get the PCB ready for this project after making the breadboard edition.

Then, we connect an LED, a set of resistors, and a buzzer to GPIO 0.

In this project, connection is relatively straightforward.

The next step is PCB Design, which consists of importing a Bell shape that was downloaded from the internet as a black-and-white BMP image into the PCB Editor.

I added the buzzer on top and all the THT components, such as XIAO, on the back. I added the SMD components on top.

Seeed Fusion Sevice

01 (10).gif
IMG_20221225_124010.jpg

As for the PCBs of the Bell Project, they were sent to SEEED Studio for samples.

An order was placed for a yellow solder mask with white silkscreen, and PCBs arrived in less than a week, which was super fast.

The quality was very good considering the price, which was also pretty low.

The PCB Quality of this BELL PCB WAS SUPER!

Seeed Fusion PCB Service offers one-stop prototyping for PCB manufacture and PCB assembly and as a result, they produce superior quality PCBs and Fast Turnkey PCBA within 7 working days.

Seeed Studio Fusion PCB Assembly Service takes care of the entire fabrication process, from PCB manufacturing and parts sourcing to assembly and testing services, so you can be sure they are getting a quality product.

After gauging market interest and verifying a working prototype, Seeed Propagate Service can help you bring the product to market with professional guidance and a strong network of connections.

Next, we prepare for the circuit construction process.

PCB Assembly

06 (11).gif
07 (10).gif
08 (12).gif
09 (12).gif
  • Board Assembly Process begins by first adding solder paste to each component pad one by one.
  • Next, using a tweezer, we pick all the SMD Components and place them in their designated position.
  • Following that, we carefully lifted the entire circuit board and set it down on the Mini SMT Hotplate, which heats the PCB from below up to the solder paste melting temperature. As soon as the PCB reaches that temperature, the solder paste melts, and all the components are connected to their pads.

THT Components Assembly

10 (11).gif
11 (12).gif
12 (10).gif
13 (10).gif

The remaining THT parts, such as the header pins on the board's bottom side and the buzzer on its top side, are added.

The board is now finished, and we can place the XIAO Dev Board using header pins in its location.

Result

PCB Christmas Bell Project
15 (9).gif
IMG_20221225_231657.jpg
IMG_20221225_231704.jpg

The end result of this construction is a working Jingle Bell that plays three-holiday tunes using a tiny Piezo Buzzer.

To hear the bell's true sound, watch the video that is attached.

Currently, this configuration only plays three songs, but we may add more songs, play them repeatedly, or modify the order in which they are played by adding extra buttons or selecting a different song.

This concept is for version 2, which will likely be created the following year.

If you need any help regarding this project, do leave a comment.

Thanks for reading this article, and I will be back with a new project soon.

Peace.