DIY GUY Chris
Published © Apache-2.0

Electronic Christmas tree

If you want to celecbrate the Christmas this year by a special way then this will be your best guide to make an amazing Christmas tree.

BeginnerFull instructions provided20 hours1,193
Electronic Christmas tree

Things used in this project

Story

Read more

Schematics

Schematic

GERBER files

Code

Arduino code

Arduino
#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;
    }
  }
  
}

Credits

DIY GUY Chris

DIY GUY Chris

51 projects • 341 followers
I'm having fun while making electronics projects, I am an electrical engineer in love with "Do It Yourself" tasks.
Thanks to JLCPCB.

Comments