An arduino HID controller for Spotify via the Spotify Web API. Final project for CS 207 - Building Interactive Gadgets.
- /.idea - Contains project information for IntelliJ
- /arduino - Contains .ino file to run on Arduino
- /src - Contains Java files
- /target/classes - Contains information on Java classes for compiler
- /pom.xml - Maven dependencies
- /schem.png - Breadboard diagram of circuit
Keep in mind that this project was strictly intended for my own personal use - it is not designed with user-friendliness in mind whatsoever. The code must be manually edited and compiled in order to be used.
Building this project requires:
- Arduino UNO
- Breadboard
- 5x pushbutton
- 5x 10k ohm resistor
- 1x potentiometer
- 1x 16x2 LCD screen with I2C shield (preferably this one)
- Some male-to-male and male-to-female jumper wires
The schematic is as shown:
You may notice that the LCD screen is missing - this is due to Fritzing not including the LCD with shield that I used when originally building this project.
Assuming you have the same LCD as linked above, connecting the LCD screen is relatively simple:
- GND on LCD -> GND on Arduino
- VCC on LCD -> 5V on Arduino
- SDA on LCD -> SDA on Arduino
- SCL on LCD -> SCL on Arduino
If you are attempting to build this with a different LCD screen/shield, you may have to use different pins or alter the arduino code. See the hd44780 library for more details.
In order for the program to control your Spotify account, it must be provided with an access token. This program does not contain a built-in authorization flow to obtain a token for you - you must obtain this token manually.
The easiest way to do this is to go to this link, select GET TOKEN, check all of the boxes, and finally click REQUEST TOKEN. You should be redirected to the same page. The string that appears next to the GET TOKEN button is your access token.
This token must be manually placed in InputListener.java on line 19: static String access_token = "
[your token here]";
Keep in mind that this access token only lasts one hour - once it has expired, you must obtain a new one and restart the program.
Setting this up requires the Arduino IDE and a Java IDE. I would recommend using IntelliJ IDEA in a Maven project, as this is what was used during development.
First, upload the Arduino sketch to the arduino, and then run InputListener.java. Once you see "Started" in the Java output, it should be ready for use.
Any song titles/artists with non-UTF-8 characters will not be displayed properly. This includes any non-english language characters and non-standard symbols. This is due to limitations with both sending serial data to Arduino and the LCD display itself. The display should fix itself upon switching to a new track that can be read properly.
-
jSerialComm Java library, extremely useful for sending/recieving data over serial
-
hd44780 Arduino library, extremely useful for using the LCD screen