summaryrefslogtreecommitdiff
path: root/arduino/rgb/rgb.inoold
diff options
context:
space:
mode:
authordaniel-Jones <daniel@danieljon.es>2017-02-13 16:06:14 +1030
committerdaniel-Jones <daniel@danieljon.es>2017-02-13 16:06:14 +1030
commit38d8f89f2f2b27fb25e0b4b9a34b45b76f6dc6f2 (patch)
tree0db331dc9834acd3aed82033012d840946d02dfd /arduino/rgb/rgb.inoold
parentf7bbb4f3d4325df390ce54cbb46c99a964a5a508 (diff)
downloadRGB-Controller-38d8f89f2f2b27fb25e0b4b9a34b45b76f6dc6f2.tar.gz
RGB-Controller-38d8f89f2f2b27fb25e0b4b9a34b45b76f6dc6f2.zip
added fade ability to Arduino sketch, using psuedo threading. Rework of serial communication also started, the Qt interface is currently under development to support fading.
Diffstat (limited to 'arduino/rgb/rgb.inoold')
-rw-r--r--arduino/rgb/rgb.inoold44
1 files changed, 44 insertions, 0 deletions
diff --git a/arduino/rgb/rgb.inoold b/arduino/rgb/rgb.inoold
new file mode 100644
index 0000000..702fbe1
--- /dev/null
+++ b/arduino/rgb/rgb.inoold
@@ -0,0 +1,44 @@
+int incomingByte = 0; // for incoming serial data
+const int redPin = 2;
+const int greenPin = 4;
+const int bluePin = 3;
+
+int red;
+int green;
+int blue;
+
+String inData;
+void setup() {
+ Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
+ red = 0;
+ green = 0;
+ blue = 0;
+ pinMode(redPin, OUTPUT);
+ pinMode(greenPin, OUTPUT);
+ pinMode(bluePin, OUTPUT);
+}
+
+void loop() {
+
+ // send data only when you receive data:
+ if (Serial.available() > 0) {
+ char recieved = Serial.read();
+ inData += recieved;
+
+ // Process message when new line character is recieved
+ if (recieved == '\n')
+ {
+ Serial.print("string: ");
+ Serial.print(inData);
+ String first = Serial.readStringUntil(',');
+ Serial.read(); //next character is comma, so skip it using this
+ String second = Serial.readStringUntil(',');
+ Serial.read();
+ String third = Serial.readStringUntil('\0');
+ Serial.print(first + "\n");
+ Serial.print(second + "\n");
+ Serial.print(third + "\n");
+ inData = ""; // Clear recieved buffer
+ }
+ }
+}