INTRO

This project is a device to control playback of pre-recorded music. Based on a pre-built playback engine written in Javascript, this device sends asynchronous serial messages to a computer to play the music. The playback device will echo your message back to you as an acknowledgement message when it executes your command. The device has the following features:

  • It can be operable by a user who cannot see the device.
  • The user should get an acknowledgement when they activate any control.
  • Start or stop the playback of a track (start plays track from the beginning).
  • Pause or resume playback of a track (resume plays track from last position stopped).
  • Skip ahead one track in the playlist.
  • Skip back one track in the playlist.
  • Fast-forward the current track (double speed of the track).
  • Skip to a random track in the playlist.

DESIGN CONCEPT

The general idea is to build a controller in a familar setting for new users (suppose to be blind) and it is easy to learn the control system. There are three types of control interaction here based on my understanding of use frequency: 1) An rotary encoder serves as a main controller to turn on/off the device with a sound indication (click) and switch songs (rotate). This should be the main control that the user use the most. 2) A push button to pause the current song; 3) Another push button to shuffle and play a random song.

img_4686

CIRCUIT

The circuit includes a Arduino MRK1000 as micro-controller, one rotary encoder and two push button as switches. There is no LED lights as indication, since I add a wav. file into previous music player JavaScript file as an indication tone.The circuit includes a half breadboard and a mini board stacked on top to make push buttons and rotary encoder panel on the same height.

untitled-sketch_bb

HOUSING

Since it is designed for blind users, I put all control interface on a single surface where you can reach all with one finger, and hold the box with one hand very easily. I used wood as exterior material to create a warmer and softer touch for the user. Ideally all the buttons and panel should be flush with the top surface to create a tight, durable, and seamless housing. cut_021517

CODE

#include
#include
// turn off hardware interrupts. On an M0-based board, you can skip this line
// because most of the IO pins on those boards have interrupts
#define ENCODER_USE_INTERRUPTS 0

Encoder encoder(6, 7); // initialize the encoder on pins 6 and 7
long lastPosition = 0; // last position of the knob
int lastButtonState = HIGH; // last state of the button
int fadeState = 0; // calculated level for the LED (0-255)
boolean onOffState = false; // whether the light is on or off

int pausePin = A0; // FSR is connected to analog 0
int pauseState = 0; // variable for reading the pushbutton status

const int shufflePin = A1; // the number of the pushbutton pin
int shuffleState = 0; // variable for reading the pushbutton status

void setup() {
Serial.begin(9600); // initialize serial communication
Keyboard.begin();
pinMode(2, INPUT_PULLUP); // pushbutton on pin 2
pinMode(pausePin, INPUT);
pinMode(shufflePin, INPUT);
}

void loop() {
// this section reads the sensors and determines if they’ve changed:
long encoderPos = encoder.read(); // read encoder
// calculate change in encoder:
int encoderChange = encoderPos – lastPosition;
lastPosition = encoderPos; // save current position for next time

int buttonState = digitalRead(2); // read pushbutton
if (buttonState != lastButtonState) { // if button has changed
delay(3); // wait a few ms (debounce delay)
if (buttonState == HIGH) { // if button is pressed
onOffState = !onOffState; // change on-off state¨
Keyboard.write(‘1’);
delay(1);
Keyboard.release(‘1’);
//Serial.println(“START/OFF”);
}
delay(1000);
}
lastButtonState = buttonState; // save current button state for next time

// this section sets the light level:
if (onOffState == true) { // if the light should be on
if (encoderChange != 0) { // if there was a change in the encoder
//fadeState = fadeState + encoderChange; // change the fadeState
//fadeState = constrain(fadeState, 3, 4); // constrain it to 0-255
//Serial.println(encoderChange);
if (encoderChange > 0) {
Keyboard.write(‘3’);
delay(1);
Keyboard.release(‘3’);
Serial.println(“NEXT SONG”);
}
if (encoderChange < 0) {
Keyboard.write(‘4’);
delay(1);
Keyboard.release(‘4’);
Serial.println(“PREVIOUS SONG”);
}
}
pauseState = digitalRead(pausePin);
if (pauseState == HIGH) {
Keyboard.write(‘2’);
delay(1);
Keyboard.release(‘2’);
delay(1000);
//Serial.println(“PAUSE”);
}

shuffleState = digitalRead(shufflePin);
if (shuffleState == HIGH) {
Keyboard.write(‘6’);
delay(1);
Keyboard.release(‘6’);
delay(1000);
//Serial.println(“SHUFFLE”);
}

}
}

Advertisements