You'll need to download and install the following dependencies for this project's software:
Adafruit TCS34725 Color Sensor Arduino Library
If you aren't sure how to install an Arduino library, check out this tutorial.
The software for this guide is written in python and should work with either python 2.7 or 3+ (although it was primarily tested against version 2.7).
Once you have python installed, follow these steps depending on your platform:
Install NumPy with one of the binary packages here.
Install the PIP python package manager by executing the following commands in a terminal:
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.pyFinally, install the colormath and pyserial library by executing in a terminal:
pip install colormath==1.0.9 pyserialIf you plan to use the FT232H cable, download and install the X code command line tools by following the steps in the answer here. You will also want to install the homebrew package manager too. Once those are installed you can install the required libftdi and libmpsse dependencies by executing in a terminal:
brew install libftdi
brew install swig
tar xvfz libmpsse-1.3.tar.gz
sudo make install
These steps are written for Ubuntu, but should be straightforward to adapt to other distributions. In a terminal execute the following commands:
sudo apt-get install python-numpy python-pipIf you plan to use the FT232H cable, execute the following commands to install the required software:
pip install colormath pyserial
sudo apt-get install python-dev libftdi-dev swig
tar xvfz libmpsse-1.3.tar.gz
sudo make install
Install NumPy from one of the binary installers here.
Install PIP by downloading the get-pip.py file, opening a command window, navigating to the directory with the file, and executing:
python get-pip.pyNote you might need to add python to your path to be able to run scripts from the command line. This blog post has a simple set of instructions to add python to your path.
Now execute the following command to install the required colormath and pyserial library:
pip install colormath pyserialAt this point all the dependencies for Windows are installed. Unfortunately you won't be able to use the FT232H cable with Windows because the libmpsse library doesn't support it. Stick to using an Arduino to communicate with the color sensor on Windows.
Also note that the software for this project has only been tested on a virtual machine running Windows. Everything should work on a real machine, but if you have issues send them to the github repository for the project.
Download the software for this project from its github repository by clicking this button:
If you're using an Arduino for this project, load the sketch in Arduino and upload it to your hardware. If you open the serial monitor at 115200 baud you should be able to send a question mark character ? and see the current RGB color (in floating point, with values from 0-1.0) printed.
To run the software for this project, make sure you've assembled the hardware and connected it to your computer. Open a terminal and navigate to the directory with the downloaded python scripts and execute the following command:
python run.py --helpYou should see a display of all the command line parameters for the program. Take note that either the --arduino or --ftdi parameters are required to run the program.
For example to run the program with Arduino hardware connected to /dev/ttyUSB0, execute:
python run.py --arduino /dev/ttyUSB0Or to run with an Arduino connected to COM4 on Windows, execute:
python run.py --arduino COM4To use the FTDI cable you need to specify the --ftdi option instead of the --arduino option. No port or other parameter is required when using the --ftdi option.
However, before the software is run with the --ftdi option you must disable the built in kernel driver for FTDI devices! Unfortunately the driver built in to recent Linux and Mac OS X kernels is not compatible with the libftdi library and must be temporarily disabled. The provided run_ftdi_linux.sh and run_ftdi_macos.sh shell scripts can be run to automatically disable and re-enable the drivers when running the software. These shells scripts need to be run as root with the sudo command.
For example to run with FTDI hardware on a Mac, execute:
sudo ./run_ftdi_macos.sh --ftdiOr on Linux execute:
sudo ./run_ftdi_linux.sh --ftdiBe aware when the program is running the FTDI drivers will be disabled so you will not be able to program an Arduino or communicate with other FTDI-based devices!
Once the software is running it will query the color sensor every 10 seconds, compute the temperature of the measured color, and adjust the gamma of the primary display to match the measured color temperature. Make sure to disable or close programs like f.lux before running the software as they might interfere with the gamma adjustment!
Try shining different colored lights on the sensor to trick it into seeing extreme temperatures (orange, white, or light blue LEDs work best--other colors will be too extreme).
You can press Ctrl-C at any time to quit the application.