
ARDUINO SOURCE CODE
/*
* Basic Pin setup:
* ———— —u—-
* ARDUINO 13|-> SCLK (pin 25) OUT1 |1 28| OUT channel 0
* 12| OUT2 |2 27|-> GND (VPRG)
* 11|-> SIN (pin 26) OUT3 |3 26|-> SIN (pin 11)
* 10|-> BLANK (pin 23) OUT4 |4 25|-> SCLK (pin 13)
* 9|-> XLAT (pin 24) . |5 24|-> XLAT (pin 9)
* 8| . |6 23|-> BLANK (pin 10)
* 7| . |7 22|-> GND
* 6| . |8 21|-> VCC (+5V)
* 5| . |9 20|-> 2K Resistor -> GND
* 4| . |10 19|-> +5V (DCPRG)
* 3|-> GSCLK (pin 18) . |11 18|-> GSCLK (pin 3)
* 2| . |12 17|-> SOUT (if daisy-chained, this goes to SIN of the
next TLC)
* 1| . |13 16|-> XERR
* 0| OUT14|14 15| OUT channel 15
* ———— ——–
*
* - Put the longer leg (anode) of the LEDs in the +5V and the shorter leg (cathode) in OUT(0-15).
* - +5V from Arduino -> TLC pin 21 and 19 (VCC and DCPRG)
* - GND from Arduino -> TLC pin 22 and 27 (GND and VPRG)
* - digital 3 -> TLC pin 18 (GSCLK)
* - digital 9 -> TLC pin 24 (XLAT)
* - digital 10 -> TLC pin 23 (BLANK)
* - digital 11 -> TLC pin 26 (SIN)
* - digital 13 -> TLC pin 25 (SCLK)
* - The 2K resistor between TLC pin 20 and GND will let ~20mA through each LED.
*
* If you are daisy-chaining more than one TLC, connect the SOUT of the first TLC to
* the SIN of the next. All the other pins should just be connected together:
* BLANK of TLC1 -> BLANK of TLC2 -> …
* The one exception is that each TLC needs it’s own resistor between pin 20 and GND.
*
* Alex Leone , 2008-11-26
*/
/* These two includes should go at the top of any file that uses the library */
#include “tlc_config.h”
#include “Tlc5940.h”
int analogPin = 0;
int potValue = 0;
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
/* Tlc.init() has to be called before using any of the library functions */
Tlc.init();
}
void loop()
{
/*
* This loop will create a Knight Rider-like effect if you have LEDs plugged
* into all the TLC outputs. NUM_TLCS is defined in “tlc_config.h”
*/
//int8_t direction = 1;
//for (TLC_CHANNEL_TYPE channel = 0; channel 10 && potValue 20){
Tlc.set(1,0);
Tlc.set(2, 0);
Tlc.set(3, 0);
}
if (potValue > 20 && potValue 40){
Tlc.set(4, 0);
Tlc.set(5, 0 );
Tlc.set(6, 0);
}
if (potValue > 40 && potValue 60){
Tlc.set(7, 0);
Tlc.set(8, 0 );
Tlc.set(9, 0);
}
if(potValue > 60 && potValue 80){
Tlc.set(10, 0);
Tlc.set(11, 0);
Tlc.set(12, 0);
}
if(potValue > 80 && potValue 100){
Tlc.set(13, 0);
Tlc.set(14, 0);
Tlc.set(17, 0);
}
if(potValue > 100 && potValue 120){
Tlc.set(18, 0);
Tlc.set(19, 0);
Tlc.set(20, 0);
}
if(potValue > 120 && potValue 140){
Tlc.set(21, 0);
Tlc.set(22, 0);
Tlc.set(23, 0);
}
if (potValue > 140 && potValue 160){
Tlc.set(24, 0);
Tlc.set(25, 0);
Tlc.set(26, 0);
}
if(potValue > 160 && potValue 180){
Tlc.set(27, 0);
Tlc.set(28, 0);
Tlc.set(29, 0);
}
if(potValue > 180 && potValue 200){
Tlc.set(30, 0);
Tlc.set(33, 0);
Tlc.set(34, 0);
}
if(potValue > 200 && potValue 220){
Tlc.set(35, 0);
Tlc.set(36, 0);
Tlc.set(37, 0);
}
if(potValue > 220 && potValue 240){
Tlc.set(38, 0);
Tlc.set(39, 0);
Tlc.set(40, 0);
}
//turn all the lights on to full color if the pot is turned all the way up
if(potValue > 245){
Tlc.set(1, 4095);
Tlc.set(2, 0);
Tlc.set(3, 0);
Tlc.set(4, 4095);
Tlc.set(5, 0 );
Tlc.set(6, 1000);
Tlc.set(7, 4000);
Tlc.set(8, 0 );
Tlc.set(9, 1500);
Tlc.set(10, 3000);
Tlc.set(11, 0);
Tlc.set(12, 3500);
Tlc.set(13, 1000);
Tlc.set(14, 0);
Tlc.set(17, 3000);
Tlc.set(18, 0);
Tlc.set(19, 200);
Tlc.set(20, 4095);
Tlc.set(21, 0);
Tlc.set(22, 1000);
Tlc.set(23, 4000);
Tlc.set(24, 0);
Tlc.set(25, 3095);
Tlc.set(26, 300);
Tlc.set(27, 400);
Tlc.set(28, 4095);
Tlc.set(29,0);
Tlc.set(30, 1500);
Tlc.set(33, 4000);
Tlc.set(34, 0);
Tlc.set(35, 4000);
Tlc.set(36, 3000);
Tlc.set(37, 0);
Tlc.set(38, 4095);
Tlc.set(39, 2000);
Tlc.set(40, 0);
}
/*
* Tlc.update() sends the data to the TLCs. This is when the LEDs will
* actually change.
*/
Tlc.update();
delay(75);
//if (channel == NUM_TLCS * 16 - 1) {
//direction = -1;
// }
// }
}
PROCESSING SOURCE CODE (as of 12/9/08)
PFont font;
PFont font2;
import ddf.minim.*;
import processing.serial.*;
Serial myPort; // The serial port
Minim minim;
AudioPlayer c4;
AudioPlayer cF4;
AudioPlayer d4;
AudioPlayer dF4;
AudioPlayer e4;
AudioPlayer f4;
AudioPlayer fF4;
AudioPlayer g4;
AudioPlayer gF4;
AudioPlayer a4;
AudioPlayer aF4;
AudioPlayer b4;
PImage Piano;
void setup() {
size (1200, 1200);
font =loadFont(”Baskerville-Bold-70.vlw”);
font2 =loadFont(”Baskerville-Bold-38.vlw”);
Piano =loadImage(”piano_keys_bw.jpg”);
image (Piano, 0, 0);
minim = new Minim(this);
c4 = minim.loadFile(”c4.mp3″);
cF4 =minim.loadFile(”c#4.mp3″);
d4 = minim.loadFile(”d4.mp3″);
dF4 = minim.loadFile(”d#4.mp3″);
e4 = minim.loadFile(”e4.mp3″);
f4 = minim.loadFile(”f4.mp3″);
fF4 = minim.loadFile(”f#4.mp3″);
g4 = minim.loadFile(”g4.mp3″);
gF4 = minim.loadFile(”g#4.mp3″);
a4 = minim.loadFile(”a4.mp3″);
aF4 = minim.loadFile(”a#4.mp3″);
b4 = minim.loadFile(”b4.mp3″);
println(Serial.list());
// I know that the fisrt port in the serial list on my mac
// is usually my Arduino module, so I open Serial.list()[0].
// Open whatever port is the one you’re using.
myPort = new Serial(this, Serial.list()[0], 9600);
}
void draw() {
smooth();
}
void mousePressed() {
int inByte = myPort.read();
if(mouseX > 50 && mouseX 150 && mouseX 250 && mouseX 350 &&mouseX 450 && mouseX 550 && mouseX 650 && mouseX 750 && mouseX 850 && mouseX 950 && mouseX 1050 && mouseX 1150 && mouseX
