Created
January 19, 2011 18:32
-
-
Save raster/786605 to your computer and use it in GitHub Desktop.
A simple Arduino-based Light Organ controlled by Processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* LightOrgan.pde - Arduino | |
* | |
* See also: http://rasterweb.net/raster/2011/01/19/shiftbrite-light-organ/ | |
* | |
*/ | |
#include "HughesyShiftBrite.h" | |
HughesyShiftBrite sb; | |
void setup() | |
sb = HughesyShiftBrite(10,11,12,13); | |
sb.sendColour(0,0,0); | |
Serial.begin(9600); | |
} | |
void loop() { | |
int input = Serial.read(); | |
switch (input) { | |
case 48: | |
sb.sendColour(0,0,0); | |
break; | |
case 49: | |
sb.sendColour(700,0,0); | |
break; | |
case 50: | |
sb.sendColour(0,700,0); | |
break; | |
case 51: | |
sb.sendColour(0,0,700); | |
break; | |
case 52: | |
sb.sendColour(700,700,0); | |
break; | |
case 53: | |
sb.sendColour(0,700,700); | |
break; | |
case 54: | |
sb.sendColour(700,0,700); | |
break; | |
case 55: | |
sb.sendColour(900,300,300); | |
break; | |
case 56: | |
sb.sendColour(300,900,300); | |
break; | |
case 57: | |
sb.sendColour(300,300,900); | |
break; | |
} | |
delay(5); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* LightOrganController.pde - Processing | |
* | |
* See also: http://rasterweb.net/raster/2011/01/19/shiftbrite-light-organ/ | |
* | |
*/ | |
import processing.serial.*; | |
Serial myPort; | |
void setup() { | |
println(Serial.list()); | |
myPort = new Serial(this, Serial.list()[0], 9600); | |
myPort.buffer(1); | |
size(200, 200); | |
background(0,0,0); | |
} | |
void draw() { | |
// nothing needed here | |
} | |
void keyPressed() { | |
if (int(key) == 48) { | |
myPort.write(48); | |
fill(0,0,0); | |
rect(5,5,190,190); | |
} | |
else if (int(key) == 49) { | |
myPort.write(49); | |
fill(200,0,0); | |
rect(5,5,190,190); | |
} | |
else if (int(key) == 50) { | |
myPort.write(50); | |
fill(0,200,0); | |
rect(5,5,190,190); | |
} | |
else if (int(key) == 51) { | |
myPort.write(51); | |
fill(0,0,200); | |
rect(5,5,190,190); | |
} | |
else if (int(key) == 52) { | |
myPort.write(52); | |
fill(200,200,0); | |
rect(5,5,190,190); | |
} | |
else if (int(key) == 53) { | |
myPort.write(53); | |
fill(0,200,200); | |
rect(5,5,190,190); | |
} | |
else if (int(key) == 54) { | |
myPort.write(54); | |
fill(200,0,200); | |
rect(5,5,190,190); | |
} | |
else if (int(key) == 55) { | |
myPort.write(55); | |
fill(250,125,125); | |
rect(5,5,190,190); | |
} | |
else if (int(key) == 56) { | |
myPort.write(56); | |
fill(125,250,125); | |
rect(5,5,190,190); | |
} | |
else if (int(key) == 57) { | |
myPort.write(57); | |
fill(125,125,250); | |
rect(5,5,190,190); | |
} | |
else { | |
myPort.write(48); | |
fill(0,0,0); | |
rect(5,5,190,190); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment