Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
Software apps and online services | ||||||
|
Hey guys! I Hope you already enjoyed my previous project "NodeMCU Home Automation (ESP8266)" and you are ready for a new one, as usual I made this tutorial to guide you step by step an electronic Christmas tree to celebrate the Christmas your own way, this project could be a great gift that you can give to your kids too. Follow the steps of this video and keep watching the whole video to learn how to create your own Christmas tree.
During the making of this project, we tried to make sure that this instructable will be the best guide for you in order to help you if you want to make your own christmas tree, so we hope that this instructable contain the needed documents. This project is so handy to make specially after getting the customized PCB that we’ve ordered from JLCPCB to improve the appearance of our electronic device and also there is enough documents and codes in this guide to allow you create your beautiful christmas tree with some lights and sounds. We've made this project in just 2 days only, just one days to get all the needed parts and finish the hardware making and the assemble, then one day to prepare the code to suit our project and start the testing and the adjustments.
What You Will Learn:- Making the right hardware selection for your project depending on its functionalities.
- Prepare the circuit diagram to connect all the choosen components
- Solder the electronic parts to the PCB..
- Assemble all the project parts (device box and electronic assembly)..
- Start the first test and validate the project.
The project is super easy for everyone to make, and no specific knowledge required in order to make it since it is all about controlling RBG LEDs and a piezo buzzer to display the Christmas songs and all these parts will be placed in one PCB and controlled through an ATmega328 MCU which is the same Microcontroller of the Arduino UNO
The schematic has a piezo buzzer connected to the MCU which is the main responsible of displaying christmas songs. The lights blinking will be random while the device is on. the power supply used in this project a simplu 3 lithium batteries of 1.5V which makes a 4.5V enough to turn on the MCU.
Step 2: PCB MakingJLCPCB (Shenzhen JIALICHUANG Electronic Technology Development Co., Ltd.), is the largest PCB prototype enterprise in China and a high-tech manufacturer specializing in quick PCB prototype and small-batch PCB production. With over 10 years of experience in PCB manufacturing, JLCPCB has more than 200, 000 customers at home and abroad, with over 8, 000 online orders of PCB prototyping and small quantity PCB production per day. The annual production capacity is 200, 000 sq.m. for various of 1-layer, 2-layer or multi-layer PCBs. JLC is a professional PCB manufacturer featured of large scale, well equipment, strict management and superior quality.
Talking ElectronicsAfter making the circuit design I transformed the circuit into a customized PCB design with a tree shape in order to get a beautiful PCB design when we order our circuit and to do so all what I need is to move toJLCPCBthe best PCB supplier in order to get the best PCB manufacturing service, as always just some simple clicks that’s all what you need to uploaded the appropriate GERBER files of the circuit design then I moved to set some parameters and this time we will use the green color for this PCB since we are producing a tree so it should be green anyway; just four days after placing the order and my PCBs are on my desktop.
Related Download FilesAs you can see in the pictures above the PCB is very well manufactured and I’ve got the same PCB design that we’ve made for our main board and all the labels, logos are there to guide me during the soldering steps. You can alsodownload the Gerberfile for this circuit.
Step 3: IngredientsBefore start soldering the electronic parts let’s review the components list for our project so we will need:
★☆★ The necessary components ★☆★
- The PCB that we have ordered from JLCPCB
- One Arduino UNO : https://www.utsource.net/itm/p/8647184.htmlATmega328p MCU: https://www.utsource.net/itm/p/8972480.html
- RGB LEDs : https://www.utsource.net/itm/p/8664394.html
- 220 Ohm resistors : https://www.utsource.net/itm/p/8664394.html
- 16Mhz oscillator : https://www.utsource.net/itm/p/8664394.html
- Piezo buzzer : https://www.utsource.net/itm/p/8664394.html
ow everything is ready so let’s start soldering our electronic components to the PCB and to do so we need a soldering iron and a solder core wire and a SMD rework station for SMD components.
Safety FirstSoldering Iron Never touch the element of the soldering iron....400°C! Hold wires to be heated with tweezers or clamps. Always return the soldering iron to its stand when not in use. Never put it down on the workbench. Turn unit off and unplug when not in use. As you can see, using this PCB is so easy due to its very high quality making and without forgetting the labels that will guide you guys while soldering each component because you will find on the top silk layer a label of each component indicating its placement on the board and this way you will be 100% sure that you will not make any soldering mistakes.I’ve soldered each component to its placement and you can use both sides of the PCB to solder your electronic components.
Step 5: Software Part & TestNow we have the PCB ready and all the components soldered very well so it’s time to move to the software part I have made an arduino code that you can download for free from the link below nowall what we need now is to place the MCU in an Arduino UNO board and we upload the code to the microcontroller then we take it back to its socket on our PCB after that we put the circuit board inside the glass holder and we glue it.
After placing the batteries we turn on the device and we enjoy the sound and the view.
This project is so easy to make and an amazing one and we recommend it for you if you want to celebrate the Christmas your own way. But still some other improvements to perform in our project in order to make it much more butter, that’s why I will be waiting for your comments to improve it.
#include "pt.h"
#include "timer.h"
// Set this to be the pin that your buzzer resides in. (Note that you can only have one buzzer actively using the PWM signal at a time).
int tonePin = 3;
// Define the protothreads, and also the flags that terminate the respective protothread
// Could be abstracted into an array/stack
boolean enablePtJoyToTheWorld = true;
static struct pt ptJoyToTheWorld;
boolean enablePtWeWishYouAMerry = true;
static struct pt ptWeWishYouAMerry;
boolean enablePtRudolfTheRedNosed = true;
static struct pt ptRudolfTheRedNosed;
boolean enablePtJingleBells = true;
static struct pt ptJingleBells;
boolean enablePtFlashLightsFstSeq = true;
static struct pt ptFlashLightsFstSeq;
const int LED1=0;
const int LED2=1;
const int LED3=2;
const int LED4=4;
const int LED5=5;
const int LED6=7;
const int LED7=8;
const int LED8=12;
const int LEDR=9;
const int LEDG=10;
const int LEDB=11;
long int countForLight=millis();
int colorLight=0;
int flag1=0;
int flag2=1;
int flag3=1;
int flag4=1;
int flag5=1;
int flag6=1;
int flag7=1;
int flag8=1;
int flag9=1;
int flag10=1;
int flag11=1;
int flag12=1;
void setup() {
// Setup the Protothread Variables
PT_INIT(&ptJoyToTheWorld);
PT_INIT(&ptWeWishYouAMerry);
PT_INIT(&ptRudolfTheRedNosed);
PT_INIT(&ptJingleBells);
PT_INIT(&ptFlashLightsFstSeq);
// Add a little bit of Christmas Festive
for(int i=0; i<13; i++)
{
pinMode(i,OUTPUT);
}
digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH);
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7,HIGH);
digitalWrite(LED8,HIGH);
}
/*************************************************
************* START MUSIC FUNCTIONS *************
*************************************************/
// Sounds spectacularly similar to another infamous tune...
static PT_THREAD(protothreadJingleBells(struct pt *pt)) {
static struct timer tJingleBells;
PT_BEGIN(pt);
while (enablePtJingleBells) {
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 416.6655);
timer_set(&tJingleBells, 462.961666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 416.6655);
timer_set(&tJingleBells, 462.961666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 587, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 312.499125);
timer_set(&tJingleBells, 347.22125); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 833.331);
timer_set(&tJingleBells, 925.923333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 312.499125);
timer_set(&tJingleBells, 347.22125); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 416.6655);
timer_set(&tJingleBells, 462.961666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 587, 416.6655);
timer_set(&tJingleBells, 462.961666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 416.6655);
timer_set(&tJingleBells, 462.961666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 416.6655);
timer_set(&tJingleBells, 462.961666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 587, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 312.499125);
timer_set(&tJingleBells, 347.22125); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 833.331);
timer_set(&tJingleBells, 925.923333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 312.499125);
timer_set(&tJingleBells, 347.22125); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 587, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 587, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 587, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 783, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 416.6655);
timer_set(&tJingleBells, 462.961666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 416.6655);
timer_set(&tJingleBells, 462.961666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 587, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 312.499125);
timer_set(&tJingleBells, 347.22125); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 833.331);
timer_set(&tJingleBells, 925.923333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 312.499125);
timer_set(&tJingleBells, 347.22125); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 416.6655);
timer_set(&tJingleBells, 462.961666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 587, 416.6655);
timer_set(&tJingleBells, 462.961666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 416.6655);
timer_set(&tJingleBells, 462.961666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 416.6655);
timer_set(&tJingleBells, 462.961666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 587, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 312.499125);
timer_set(&tJingleBells, 347.22125); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 833.331);
timer_set(&tJingleBells, 925.923333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 312.499125);
timer_set(&tJingleBells, 347.22125); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 104.166375);
timer_set(&tJingleBells, 115.740416667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 587, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 587, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 587, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 783, 208.33275);
timer_set(&tJingleBells, 231.480833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
/*----------------------------------------------------------------------------------------------------*/
// tone(tonePin, 587, 450.0);
// timer_set(&tJingleBells, 500.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 554, 337.5);
// timer_set(&tJingleBells, 375.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 493, 112.5);
// timer_set(&tJingleBells, 125.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 440, 675.0);
// timer_set(&tJingleBells, 750.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 391, 225.0);
// timer_set(&tJingleBells, 250.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 369, 450.0);
// timer_set(&tJingleBells, 500.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 329, 450.0);
// timer_set(&tJingleBells, 500.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 293, 675.0);
// timer_set(&tJingleBells, 750.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 440, 225.0);
// timer_set(&tJingleBells, 250.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 493, 670.3125);
// timer_set(&tJingleBells, 744.791666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// timer_set(&tJingleBells, 5.20833333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 493, 225.0);
// timer_set(&tJingleBells, 250.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 554, 670.3125);
// timer_set(&tJingleBells, 744.791666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// timer_set(&tJingleBells, 5.20833333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 554, 225.0);
// timer_set(&tJingleBells, 250.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 587, 670.3125);
// timer_set(&tJingleBells, 744.791666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// timer_set(&tJingleBells, 5.20833333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 587, 220.3125);
// timer_set(&tJingleBells, 244.791666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// timer_set(&tJingleBells, 5.20833333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 587, 225.0);
// timer_set(&tJingleBells, 250.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 554, 225.0);
// timer_set(&tJingleBells, 250.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 493, 225.0);
// timer_set(&tJingleBells, 250.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 440, 220.3125);
// timer_set(&tJingleBells, 244.791666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// timer_set(&tJingleBells, 5.20833333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 440, 337.5);
// timer_set(&tJingleBells, 375.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 391, 112.5);
// timer_set(&tJingleBells, 125.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 369, 225.0);
// timer_set(&tJingleBells, 250.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 587, 220.3125);
// timer_set(&tJingleBells, 244.791666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// timer_set(&tJingleBells, 5.20833333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 587, 225.0);
// timer_set(&tJingleBells, 250.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 554, 225.0);
// timer_set(&tJingleBells, 250.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 493, 225.0);
// timer_set(&tJingleBells, 250.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 440, 220.3125);
// timer_set(&tJingleBells, 244.791666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// timer_set(&tJingleBells, 5.20833333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 440, 337.5);
// timer_set(&tJingleBells, 375.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 391, 112.5);
// timer_set(&tJingleBells, 125.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 369, 220.3125);
// timer_set(&tJingleBells, 244.791666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// timer_set(&tJingleBells, 5.20833333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 369, 220.3125);
// timer_set(&tJingleBells, 244.791666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// timer_set(&tJingleBells, 5.20833333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 369, 220.3125);
// timer_set(&tJingleBells, 244.791666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// timer_set(&tJingleBells, 5.20833333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 369, 220.3125);
// timer_set(&tJingleBells, 244.791666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// timer_set(&tJingleBells, 5.20833333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 369, 220.3125);
// timer_set(&tJingleBells, 244.791666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// timer_set(&tJingleBells, 5.20833333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 369, 112.5);
// timer_set(&tJingleBells, 125.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 391, 112.5);
// timer_set(&tJingleBells, 125.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 440, 675.0);
// timer_set(&tJingleBells, 750.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 391, 112.5);
// timer_set(&tJingleBells, 125.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 369, 112.5);
// timer_set(&tJingleBells, 125.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 329, 220.3125);
// timer_set(&tJingleBells, 244.791666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// timer_set(&tJingleBells, 5.20833333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 329, 220.3125);
// timer_set(&tJingleBells, 244.791666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// timer_set(&tJingleBells, 5.20833333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 329, 220.3125);
// timer_set(&tJingleBells, 244.791666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// timer_set(&tJingleBells, 5.20833333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 329, 112.5);
// timer_set(&tJingleBells, 125.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 369, 112.5);
// timer_set(&tJingleBells, 125.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 391, 675.0);
// timer_set(&tJingleBells, 750.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 369, 112.5);
// timer_set(&tJingleBells, 125.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 329, 112.5);
// timer_set(&tJingleBells, 125.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 293, 225.0);
// timer_set(&tJingleBells, 250.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 587, 450.0);
// timer_set(&tJingleBells, 500.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 493, 225.0);
// timer_set(&tJingleBells, 250.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 440, 337.5);
// timer_set(&tJingleBells, 375.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 391, 112.5);
// timer_set(&tJingleBells, 125.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 369, 225.0);
// timer_set(&tJingleBells, 250.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 391, 225.0);
// timer_set(&tJingleBells, 250.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 369, 450.0);
// timer_set(&tJingleBells, 500.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
// tone(tonePin, 329, 450.0);
// timer_set(&tJingleBells, 500.0); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
/*------------------------------------------------------------------------------------------------------*/
timer_set(&tJingleBells, 3.74699652778); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 329, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 967.849203125);
timer_set(&tJingleBells, 1075.38800347); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
timer_set(&tJingleBells, 3.74699652778); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 1294.962);
timer_set(&tJingleBells, 1438.84666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 349, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 349, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 293, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 967.849203125);
timer_set(&tJingleBells, 1075.38800347); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
timer_set(&tJingleBells, 3.74699652778); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 329, 1294.962);
timer_set(&tJingleBells, 1438.84666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 329, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 967.849203125);
timer_set(&tJingleBells, 1075.38800347); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
timer_set(&tJingleBells, 3.74699652778); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 1294.962);
timer_set(&tJingleBells, 1438.84666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 349, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 349, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 293, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 967.849203125);
timer_set(&tJingleBells, 1075.38800347); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
timer_set(&tJingleBells, 3.74699652778); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 587, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 1294.962);
timer_set(&tJingleBells, 1438.84666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 320.368203125);
timer_set(&tJingleBells, 355.964670139); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
timer_set(&tJingleBells, 3.74699652778); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 329, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 647.481);
timer_set(&tJingleBells, 719.423333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 349, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 349, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 329, 1294.962);
timer_set(&tJingleBells, 1438.84666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 293, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 329, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 320.368203125);
timer_set(&tJingleBells, 355.964670139); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
timer_set(&tJingleBells, 3.74699652778); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 320.368203125);
timer_set(&tJingleBells, 355.964670139); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
timer_set(&tJingleBells, 3.74699652778); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 647.481);
timer_set(&tJingleBells, 719.423333333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 320.368203125);
timer_set(&tJingleBells, 355.964670139); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
timer_set(&tJingleBells, 3.74699652778); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 349, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 293, 809.35125);
timer_set(&tJingleBells, 899.279166667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 329, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 967.849203125);
timer_set(&tJingleBells, 1075.38800347); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
timer_set(&tJingleBells, 3.74699652778); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 1294.962);
timer_set(&tJingleBells, 1438.84666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 349, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 349, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 293, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 493, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 967.849203125);
timer_set(&tJingleBells, 1075.38800347); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
timer_set(&tJingleBells, 3.74699652778); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 440, 161.87025);
timer_set(&tJingleBells, 179.855833333); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 391, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 587, 323.7405);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
tone(tonePin, 523, 971.2215);
timer_set(&tJingleBells, 359.711666667); PT_WAIT_UNTIL(pt, timer_expired(&tJingleBells));
}
PT_END(pt);
}
/*************************************************
************** END MUSIC FUNCTIONS **************
*************************************************/
void loop()
{
protothreadJingleBells(&ptJingleBells);
colors();
}
void colors()
{
if(millis()-countForLight>10 && flag1==0)
{
countForLight=millis();
analogWrite(LEDR,0);
analogWrite(LEDG,colorLight);
digitalWrite(LEDB,0);
colorLight++;
if(colorLight==256)
{
flag1=1;
flag2=0;
colorLight=0;
}
}
if(millis()-countForLight>10 && flag2==0)
{
countForLight=millis();
analogWrite(LEDR,colorLight);
analogWrite(LEDG,0);
digitalWrite(LEDB,1);
colorLight++;
if(colorLight==256)
{
flag2=1;
flag3=0;
colorLight=0;
}
}
if(millis()-countForLight>10 && flag3==0)
{
countForLight=millis();
analogWrite(LEDR,random(0,255));
analogWrite(LEDG,0);
analogWrite(LEDB,0);
colorLight++;
if(colorLight==700)
{
flag3=1;
flag4=0;
colorLight=0;
digitalWrite(LED1,HIGH);
digitalWrite(LED2,LOW);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,LOW);
digitalWrite(LED5,HIGH);
digitalWrite(LED6,LOW);
digitalWrite(LED7,HIGH);
digitalWrite(LED8,LOW);
}
}
if(millis()-countForLight>100 && flag4==0)
{
countForLight=millis();
analogWrite(LEDR,colorLight);
analogWrite(LEDG,random(0,255));
digitalWrite(LEDB,1);
digitalWrite(LED1,!digitalRead(LED1));
digitalWrite(LED2,!digitalRead(LED2));
digitalWrite(LED3,!digitalRead(LED3));
digitalWrite(LED4,!digitalRead(LED4));
digitalWrite(LED5,!digitalRead(LED5));
digitalWrite(LED6,!digitalRead(LED6));
digitalWrite(LED7,!digitalRead(LED7));
digitalWrite(LED8,!digitalRead(LED8));
colorLight++;
if(colorLight==120)
{
flag4=1;
flag5=0;
colorLight=0;
digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH);
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7,HIGH);
digitalWrite(LED8,HIGH);
}
}
if(millis()-countForLight>10 && flag5==0)
{
countForLight=millis();
analogWrite(LEDR,128);
analogWrite(LEDG,colorLight);
digitalWrite(LEDB,1);
colorLight++;
if(colorLight==256)
{
flag5=1;
flag6=0;
colorLight=0;
}
}
if(millis()-countForLight>10 && flag6==0)
{
countForLight=millis();
analogWrite(LEDR,colorLight);
analogWrite(LEDG,128);
analogWrite(LEDB,0);
colorLight++;
if(colorLight==256)
{
flag6=1;
flag7=0;
colorLight=0;
}
}
if(millis()-countForLight>10 && flag7==0)
{
countForLight=millis();
analogWrite(LEDR,colorLight);
analogWrite(LEDG,180);
analogWrite(LEDB,0);
colorLight++;
if(colorLight==256)
{
flag7=1;
flag8=0;
colorLight=0;
}
}
if(millis()-countForLight>10 && flag8==0)
{
countForLight=millis();
analogWrite(LEDR,random(0,255));
analogWrite(LEDG,random(0,255));
digitalWrite(LEDB,1);
colorLight++;
if(colorLight==700)
{
flag8=1;
flag9=0;
colorLight=0;
}
}
if(millis()-countForLight>10 && flag9==0)
{
countForLight=millis();
analogWrite(LEDR,0);
analogWrite(LEDG,random(0,255));
analogWrite(LEDB,0);
colorLight++;
if(colorLight==700)
{
flag9=1;
flag1=0;
colorLight=0;
}
}
}
Comments