Device Art Final: Turntable for Night Owls

Introduction: Device Art Final: Turntable for Night Owls

1. [Rotating a turntable] Prepare laser-cut wood pieces (2 rectangles, 2 squares, 1 circle)

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1:

2. Mark the center point of one rectangle panel and drill it, large enough to fit a servo motor’s circle

Step 2:

3. Attach a part of servo motor on a circle panel with a tape

Step 3:

4. Connect the circle panel right on the center of the rectangle panel.

Step 4:

5. [Pulse sensor and MP3 speaker on a breadboard] Before making a circuit, make sure to download MP3 files in micro SD card and put it in a MP3 sensor.

Step 5:

6. Make the same circuit as above for connecting a MP3 player and a pulse sensor.

Step 6:

7. Complete attaching a servo motor — a circle panel and the motor itself.

Step 7:

8. Put all the circuits within the box and enclose it with another rectangle panel.

Step 8:

9. Copy and paste the codes below into Arduino Uno.

#include

#include "SoftwareSerial.h"

SoftwareSerial mySerial(10, 11);

# define Start_Byte 0x7E

# define Version_Byte 0xFF

# define Command_Length 0x06

# define End_Byte 0xEF

# define Acknowledge 0x00 //Returns info with command 0x41 [0x01: info, 0x00: no info]

# define ACTIVATED LOW

int buttonNext = 2;

int buttonPause = 3;

int buttonPrevious = 4;

boolean isPlaying = false;

Servo servo_9;

#include

const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution

// for your motor

// initialize the stepper library on pins 8 through 11:

Stepper myStepper(stepsPerRevolution, 5, 6, 7, 8);

#define USE_ARDUINO_INTERRUPTS true // Set-up low-level interrupts for most acurate BPM math.

#include // Includes the PulseSensorPlayground Library.

// Variables

const int PulseWire = 0; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0

const int LED13 = 13; // The on-board Arduino LED, close to PIN 13.

int Threshold = 550;

PulseSensorPlayground pulseSensor;

void setup () {

Serial.begin(9600);

servo_9.attach(9);

pulseSensor.analogInput(PulseWire);

pulseSensor.blinkOnPulse(LED13); //auto-magically blink Arduino's LED with heartbeat.

pulseSensor.setThreshold(Threshold);

// Double-check the "pulseSensor" object was created and "began" seeing a signal.

if (pulseSensor.begin()) {

Serial.println("We created a pulseSensor Object !"); //This prints one time at Arduino power-up, or on Arduino reset.

}

pinMode(buttonPause, INPUT);

digitalWrite(buttonPause,HIGH);

pinMode(buttonNext, INPUT);

digitalWrite(buttonNext,HIGH);

pinMode(buttonPrevious, INPUT);

digitalWrite(buttonPrevious,HIGH);

mySerial.begin (9600);

delay(1000);

//playFirst();

//isPlaying = true;

pause();

}

void loop () {

myStepper.setSpeed(100);

// step 1/100 of a revolution:

myStepper.step(stepsPerRevolution/

100 );

int myBPM = pulseSensor.getBeatsPerMinute(); // Calls function on our pulseSensor object that returns BPM as an "int".

//// delay(5000) ; // "myBPM" hold this BPM value now.

/

/if (pulseSensor.sawStartOfBeat()) { // Constantly test to see if "a beat happened".

// Serial.println("♥ A HeartBeat Happened ! "); // If test is "true", print a message "a heartbeat happened".

// Serial.print("BPM: "); // Print phrase "BPM: "

Serial.println(myBPM); // Print the value inside of myBPM.

//}

/

/

//

if(myBPM<120){

isPlaying = true;

play();

servo_9.write(180);

}

else if(myBPM>170){

// pause();

playNext();

// servo_9.write(0);

}

// if(myBPM>140){

// playNext();

// }

}

// if (digitalRead(buttonPause) == ACTIVATED)

// {

// if(isPlaying)

// {

// pause();

// isPlaying = false;

// }else

// {

// isPlaying = true;

// play();

// }

// }

/

/ if (digitalRead(buttonNext) == ACTIVATED)

// {

// if(isPlaying)

// {

// playNext();

// }

// }

/

/ if (digitalRead(buttonPrevious) == ACTIVATED)

// {

// if(isPlaying)

// {

// playPrevious();

// }

// }

void playFirst()

{

execute_CMD(0x3F, 0, 0);

delay(500);

setVolume(20);

delay(500);

execute_CMD(0x11,0,1);

delay(500);

}

void pause()

{

execute_CMD(0x0E,0,0);

delay(500);

}

void play()

{

execute_CMD(0x0D,0,1);

delay(500);

}

void playNext()

{

execute_CMD(0x01,0,1);

delay(500);

}

void playPrevious()

{

execute_CMD(0x02,0,1);

delay(500);

}

void setVolume(int volume)

{

execute_CMD(0x06, 0, volume); // Set the volume (0x00~0x30)

delay(2000);

}

void execute_CMD(byte CMD, byte Par1, byte Par2)

// Excecute the command and parameters

{

// Calculate the checksum (2 bytes)

word checksum = -(Version_Byte + Command_Length + CMD + Acknowledge + Par1 + Par2);

// Build the command line

byte Command_line[10] = { Start_Byte, Version_Byte, Command_Length, CMD, Acknowledge,

Par1, Par2, highByte(checksum), lowByte(checksum), End_Byte};

//Send the command line to the module

for (byte k=0; k<10; k++)

{

mySerial.write( Command_line[k]);

}

}

Step 9:

10. It starts playing music and rotating a turntable depending on your heart rate :)

Be the First to Share

    Recommendations

    • Magnets Challenge

      Magnets Challenge
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    Discussions