summaryrefslogtreecommitdiff
path: root/Arduino sketch
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2011-01-29 23:19:05 +0100
committerKevin Chabowski <kevin@kch42.de>2011-01-29 23:19:05 +0100
commitaedc42f9ff57eb7fb456ef6fd9e94c099ff84076 (patch)
treecff85e6903990a6bfd87b5b047722f693352b623 /Arduino sketch
downloadSerialRGB-LED-Arduino-aedc42f9ff57eb7fb456ef6fd9e94c099ff84076.tar.gz
SerialRGB-LED-Arduino-aedc42f9ff57eb7fb456ef6fd9e94c099ff84076.tar.bz2
SerialRGB-LED-Arduino-aedc42f9ff57eb7fb456ef6fd9e94c099ff84076.zip
Initial commit
Diffstat (limited to 'Arduino sketch')
-rw-r--r--Arduino sketch/serial_rgb.pde28
1 files changed, 28 insertions, 0 deletions
diff --git a/Arduino sketch/serial_rgb.pde b/Arduino sketch/serial_rgb.pde
new file mode 100644
index 0000000..84d331b
--- /dev/null
+++ b/Arduino sketch/serial_rgb.pde
@@ -0,0 +1,28 @@
+#define LEDR 9
+#define LEDG 10
+#define LEDB 11
+
+int r, g, b;
+
+void setup()
+{
+ pinMode(LEDR, OUTPUT);
+ pinMode(LEDG, OUTPUT);
+ pinMode(LEDB, OUTPUT);
+ r = g = b = 0;
+
+ Serial.begin(9600);
+}
+
+void loop()
+{
+ if(Serial.available() >= 3)
+ {
+ r = Serial.read();
+ g = Serial.read();
+ b = Serial.read();
+ }
+ analogWrite(LEDR, r);
+ analogWrite(LEDG, g);
+ analogWrite(LEDB, b);
+}