Interactive Assignment – Amelia Lozada

For my interactive project I chose to make an interactive coded song. First, I started off by choosing a snippet of a song I wanted and then converting it from an mp4 file to midi file. Then upload it to a site that converts the song into a code for Arduino. The outcome ended up being a melody made of beeps that take from the melody of the song. Then in order for the song to become more interactive I played with a tachometer code that uses the lights on the circuit playground to sense motion. The song code and tachometer code were then combined to create the final code for this project. In terms of how one would interact with this is I used a record player and a thrifted record. The record player allows you to adjust the speed of the record when it plays, so I hid the circuit playground under the tip of the record where I placed reflective tape so that it would reflect off of the LEDs and sense how fast the record was going. When you change the speed the song will play slower or faster depending on the speed you set it to.

Video: IMG_0878

Code:

// Adafruit Circuit Playground Fidget Spinner Tachometer with LED Display
//
// This sketch uses the light sensor built in to Circuit Playground
// to detect the speed (in revolutions per second) of a fidget spinner
// and display it on a connected 4-digit 7-segment LED backpack display.
// See the tachometer example (without led_display) for a version that
// will output just to the serial monitor with no extra hardware needed.
//
// Load the sketch on a Circuit Playground (either classic or express)
// and notice the first three NeoPixels will turn on bright white.
// Hold a spinning fidget spinner very close to (but not touching) the
// light sensor (look for the eye graphic on the board, it’s right
// below the three lit NeoPixels) and the sketch will display the
// revolutions per second of the spinner on the LED display. Hold
// the spinner perpendicular to the light sensor for the best
// measurement:
// ||
// || <- Spinner
// ||
// ________ <- Circuit Playground
//
// Author: Tony DiCola
// License: MIT License (https://en.wikipedia.org/wiki/MIT_License)

#include <Adafruit_CircuitPlayground.h>
#include “pt.h” // include protothread library
#include “pt-sleep.h” // include protothread library

static struct pt ptsong_loop;
static struct pt tachometer;

// Configuration values. You don’t have to change these but they’re
// interesting to adjust the logic. If your spinner has more or less
// than three arms be sure to change the SPINNER_ARMS value below:
#define SPINNER_ARMS 27 // Number of arms on the fidget spinner.
// This is used to calculate the true
// revolutions per second of the spinner
// as one full revolution of the spinner
// will actually see this number of cycles
// pass by the light sensor. Set this to
// the value 1 to ignore this calculation
// and just see the raw cycles / second.

#define SAMPLE_DEPTH 200 // How many samples to take when measuring
// the spinner speed. The larger this value
// the more memory that will be consumed but
// the slower a spinner speed that can be
// detected (larger sample depths mean longer
// period waves can be detected). You’re
// limited by the amount of memory on the
// board for this value. On a classic
// Circuit Playground with 2kb of memory
// you can only go up to about 512 or so (each
// sample is 2 bytes, so 1kb of space total).
// On an express board you can go much higher,
// like up to 10240 for 20kb of sample data.

#define SAMPLE_PERIOD_US 2800 // Amount of time in *microseconds* to delay
// between each light sensor sample. This is
// a balance between how fast and slow of
// a spinner reading that can be measured.
// The higher this value the slower a spinner
// you can measure, but at the tradeoff of
// not accurately measuring fast spinners.
// Low values (even 0) mean very fast speeds
// can be detected but slow speeds (below 10hz)
// are harder to detect. You can increase the
// sample depth to help improve the range
// of detection speeds, but there’s a limit
// based on the memory available.

#define THRESHOLD 250 // 300 // How big the amplitude of a cyclic
// signal has to be before the measurement
// logic kicks in. This is a value from
// 0 to 1023 and might need to be adjusted
// up or down if the detection is too
// sensitive or not sensitive enough.
// Raising this value will make the detection
// less sensitive and require a very large
// difference in amplitude (i.e. a very close
// or highly reflective spinner), and lowering
// the value will make the detection more
// sensitive and potentially pick up random
// noise from light in the room.

//#define MEASURE_PERIOD_MS 800 // Number of milliseconds to wait
#define MEASURE_PERIOD_MS 900 // Number of milliseconds to wait
// between measurements. Default is
// one second (1000 milliseconds).

float orig_delay_times[13] = {12.7877237852, 25.5754475703, 38.3631713555, 127.877237852,
51.1508951407, 115.089514066, 63.9386189258, 89.5140664962, 153.452685422, 537.084398977,
76.726342711, 140.664961637, 728.900255754
};
float updated_delay_times[13];

static float speedy = 1; // this is the variable that needs to be mapped to the tachometer
static float currentSpeedy[1] = {speedy};
static float rpm = 0;
static float rpm_holder[1] = {rpm};

void setup() {
// Initialize serial monitor at 115200 baud.
Serial.begin(115200);
PT_INIT(&ptsong_loop); // protothread variable
PT_INIT(&tachometer); // protothread variable

// Initialize CircuitPlayground library and turn on the first 3 pixels (near the light sensor)
// to pure white at maximum brightness.
CircuitPlayground.begin(254); // 255 means set pixel colors to max brightness.
CircuitPlayground.clearPixels();
CircuitPlayground.setPixelColor(0, 255, 255, 255); // Set pixel 0, 1, 2 to white.
CircuitPlayground.setPixelColor(1, 255, 255, 255);
CircuitPlayground.setPixelColor(2, 255, 255, 255);
}

static int tachometer_loop(struct pt *pt)
{
PT_BEGIN(pt);
// Pause between measurements.
PT_SLEEP(pt, MEASURE_PERIOD_MS);
//delay(MEASURE_PERIOD_MS);

// Collect samples from the light sensor as quickly as possible.
// Keep track of the amount of time (in microseconds) between samples
// so the sampling frequency can later be determined.
uint16_t samples[SAMPLE_DEPTH] = {0};
uint32_t start = micros();
for (int i = 0; i < SAMPLE_DEPTH; ++i) {
samples[i] = CircuitPlayground.lightSensor();
delayMicroseconds(SAMPLE_PERIOD_US);
}

uint32_t elapsed_uS = micros() – start;
float elapsed = elapsed_uS / 1000000.0; // Elapsed time in seconds.

// Find the min and max values in the collected samples.
uint16_t minval = samples[0];
uint16_t maxval = samples[0];
for (int i = 1; i < SAMPLE_DEPTH; ++i) {
minval = min(minval, samples[i]);
maxval = max(maxval, samples[i]);
}

// Check the amplitude of the signal (difference between min and max)
// is greater than the threshold to continue detecting speed.
uint16_t amplitude = maxval – minval;
if (amplitude < THRESHOLD) {
// Didn’t make it past the threshold so start over with another measurement attempt.
// return;
Serial.println(“No spinning detected”);
rpm = 0;
rpm_holder[0] = 0;
loop();
}

// Compute midpoint of the signal (halfway between min and max values).
uint16_t midpoint = minval + (amplitude / 2);

// Count how many midpoint crossings were found in the signal.
// These are instances where two readings either straddle or land on
// the midpoint. The midpoint crossings will happen twice for every
// complete sine wave cycle (once going up and again coming down).
int crossings = 0;
for (int i = 1; i < SAMPLE_DEPTH; ++i) {
uint16_t p0 = samples[i – 1];
uint16_t p1 = samples[i];
if ((p1 == midpoint) ||
((p0 < midpoint) && (p1 > midpoint)) ||
((p0 > midpoint) && (p1 < midpoint))) {
crossings += 1;
}
}

// Compute signal frequency, RPM, and period.
// The period is the amount of time it takes for a complete
// sine wave cycle to occur. You can calculate this by dividing the
// amount of time that elapsed during the measurement period by the
// number of midpoint crossings cut in half (because each complete
// sine wave cycle will have 2 midpoint crossings). However since
// fidget spinners have multiple arms you also divide by the number
// of arms to normalize the period into a value that represents the
// time taken for a complete revolution of the entire spinner, not
// just the time between one arm and the next.
float period = elapsed / (crossings / SPINNER_ARMS / 2.0);

// Once the period is calculated it can be converted into a frequency
// value (i.e revolutions per second, how many times the spinner spins
// around per second) and more common RPM value (revolutions per minute,
// just multiply frequency by 60 since there are 60 seconds in a minute).
float frequency = 1.0 / period;
rpm = frequency * 60.0;

rpm = constrain(rpm, 0, 160); // constrain this to the highest rpm expected
rpm_holder[0] = rpm;
speedy = map(rpm, 0, 160, 25, 5); // slow to half or speed to up to 1.5 times
speedy = constrain(speedy, 5, 25);
speedy = speedy * .1;
// Print out the measured values!
// Serial.print(“Frequency: “);
// Serial.print(frequency, 3);
//Serial.print(” (hz)\t\tRPM: “);
Serial.print(“Speed multiplier: “);
Serial.print(speedy, 3);
Serial.print(“\t\tRPM: “);
Serial.print(rpm, 3);
Serial.print(“\t\tPeriod: “);
Serial.print(period, 3);
Serial.println(” (seconds)”);

for (int i = 0; i < 13; i++) {
updated_delay_times[i] = orig_delay_times[i] * speedy;
}

PT_END(pt);
}

static int proto_song_loop(struct pt *pt) {
PT_BEGIN(pt);
while (rpm_holder[0] > 0) {
CircuitPlayground.playTone(311, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(880, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(2637, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(1760, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[6]);
CircuitPlayground.playTone(2637, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(659, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[3]);
CircuitPlayground.playTone(1567, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[5]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(880, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(1318, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(440, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[9]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(440, updated_delay_times[7]);
PT_SLEEP(pt, updated_delay_times[7]);
PT_SLEEP(pt, updated_delay_times[8]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(1975, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(1318, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(659, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(440, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(1760, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(659, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(1975, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(1318, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(880, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[6]);
CircuitPlayground.playTone(2637, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(1318, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
CircuitPlayground.playTone(659, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(1975, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(830, updated_delay_times[10]);
PT_SLEEP(pt, updated_delay_times[10]);
CircuitPlayground.playTone(2489, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[6]);
PT_SLEEP(pt, 102.301790281);
CircuitPlayground.playTone(1975, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(1318, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(1975, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[4]);
CircuitPlayground.playTone(1975, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(830, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
CircuitPlayground.playTone(415, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, 460.358056266);
CircuitPlayground.playTone(1396, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, 242.966751918);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(1661, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(2489, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, 191.815856777);
CircuitPlayground.playTone(1661, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
CircuitPlayground.playTone(2489, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(1661, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[8]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(2489, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(830, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
PT_SLEEP(pt, 166.240409207);
CircuitPlayground.playTone(1396, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(2489, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
CircuitPlayground.playTone(830, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, 102.301790281);
PT_SLEEP(pt, updated_delay_times[10]);
CircuitPlayground.playTone(1318, updated_delay_times[5]);
PT_SLEEP(pt, updated_delay_times[5]);
CircuitPlayground.playTone(1975, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(659, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[4]);
CircuitPlayground.playTone(1975, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[6]);
CircuitPlayground.playTone(1244, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[6]);
CircuitPlayground.playTone(415, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, 549.872122762);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(415, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
PT_SLEEP(pt, 166.240409207);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(659, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(1975, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(1318, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(440, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(830, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(2489, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(659, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(1318, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(830, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(2489, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(1975, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
CircuitPlayground.playTone(1318, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(659, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(2637, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
CircuitPlayground.playTone(880, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[3]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(1318, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(659, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(1975, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[4]);
CircuitPlayground.playTone(1567, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[10]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(440, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[6]);
CircuitPlayground.playTone(1318, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[12]);
CircuitPlayground.playTone(2637, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(880, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(2637, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(1760, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[11]);
CircuitPlayground.playTone(880, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(1760, updated_delay_times[10]);
PT_SLEEP(pt, updated_delay_times[10]);
PT_SLEEP(pt, 166.240409207);
PT_SLEEP(pt, updated_delay_times[10]);
CircuitPlayground.playTone(1760, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(1760, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[6]);
CircuitPlayground.playTone(880, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[4]);
CircuitPlayground.playTone(440, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(2637, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
PT_SLEEP(pt, 102.301790281);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(2637, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(659, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[5]);
CircuitPlayground.playTone(1567, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[6]);
PT_SLEEP(pt, 102.301790281);
PT_SLEEP(pt, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(880, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(1318, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(440, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, 549.872122762);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(1318, updated_delay_times[7]);
PT_SLEEP(pt, updated_delay_times[7]);
CircuitPlayground.playTone(440, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[8]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(1975, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(659, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(440, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
CircuitPlayground.playTone(1760, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[6]);
CircuitPlayground.playTone(1975, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[6]);
CircuitPlayground.playTone(1318, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(880, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(1975, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(1318, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(659, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(1975, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(830, updated_delay_times[10]);
PT_SLEEP(pt, updated_delay_times[10]);
CircuitPlayground.playTone(2489, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[6]);
PT_SLEEP(pt, 102.301790281);
CircuitPlayground.playTone(1975, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(1318, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(1975, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(1975, updated_delay_times[10]);
PT_SLEEP(pt, updated_delay_times[10]);
PT_SLEEP(pt, updated_delay_times[6]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(830, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(415, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, 741.68797954);
PT_SLEEP(pt, updated_delay_times[4]);
CircuitPlayground.playTone(1661, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(2489, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, 191.815856777);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(440, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(1661, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(2489, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(1661, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[8]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(2489, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(830, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
PT_SLEEP(pt, 166.240409207);
CircuitPlayground.playTone(1396, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[2]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[2]);
CircuitPlayground.playTone(1661, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(32, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[7]);
CircuitPlayground.playTone(32, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(32, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(32, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(32, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(32, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(32, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(32, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(1975, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[4]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(415, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(1567, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(34, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(415, updated_delay_times[1]);
PT_SLEEP(pt, updated_delay_times[1]);
CircuitPlayground.playTone(34, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[4]);
CircuitPlayground.playTone(34, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(466, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(622, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(1046, updated_delay_times[0]);
PT_SLEEP(pt, updated_delay_times[0]);
CircuitPlayground.playTone(1174, updated_delay_times[0]);
PT_END(pt);
}
}

void loop() {
while (PT_SCHEDULE(tachometer_loop(&tachometer))) {
PT_SCHEDULE(proto_song_loop(&ptsong_loop));
}
}