summaryrefslogtreecommitdiff
path: root/Arduino sketch
diff options
context:
space:
mode:
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);
+}