Browse files

Updated Arduino sketch and ArduinoDioderCommunicationController.m for…

… new electrical layout in the LED shield.
  • Loading branch information...
1 parent b3a1b17 commit 45c6c2ae75c42485eb9efad475c62ca25255dc3c Daniel Kennett committed Oct 15, 2011
View
11 Arduino Projects/FourChannelRGBSmartListener/FourChannelRGBSmartListener.pde
@@ -7,16 +7,17 @@ analog pins.
To keep a bit of sanity, the 12-byte chunks need to be preceded by
a two-byte header and tailed by a one-byte XOR checksum of the body.
+No assumptions are made about colours except that there are twelve
+channels starting at kChannel1FirstPin.
+
NOTE: This project requires Arduino Mega.
DOUBLE NOTE: This program implements the listening side of the messages
sent by all of the included Xcode projects. Don't use the DumbListener,
because it's dumb.
*/
-// It is assumed that the channels are connected RGBRGBRGBRGB from kChannel1RedPin.
-
-const int kChannel1RedPin = 2;
+const int kChannel1FirstPin = 2;
// Protocol details (two header bytes, 12 value bytes, checksum)
@@ -34,7 +35,7 @@ byte receivedMessage[12];
void setup() {
// set pins 2 through 13 as outputs:
- for (int thisPin = kChannel1RedPin; thisPin < (kChannel1RedPin + sizeof(receivedMessage)); thisPin++) {
+ for (int thisPin = kChannel1FirstPin; thisPin < (kChannel1FirstPin + sizeof(receivedMessage)); thisPin++) {
pinMode(thisPin, OUTPUT);
analogWrite(thisPin, 255);
}
@@ -87,7 +88,7 @@ void loop () {
if (receivedChecksum == calculatedChecksum) {
// Hooray! Push the values to the output pins.
for (int i = 0; i < kProtocolBodyLength; i++) {
- analogWrite(i + kChannel1RedPin, receivedMessage[i]);
+ analogWrite(i + kChannel1FirstPin, receivedMessage[i]);
}
Serial.print("OK");
View
24 Xcode Projects/ArduinoDioderCommunicationController.m
@@ -218,21 +218,21 @@ -(void)writeColorsToChannel1:(NSColor *)channel1 channel2:(NSColor *)channel2 ch
message.header[0] = kHeaderByte1;
message.header[1] = kHeaderByte2;
- message.colors[0] = (unsigned char)([rgbChannel1 redComponent] * 255);
- message.colors[1] = (unsigned char)([rgbChannel1 greenComponent] * 255);
- message.colors[2] = (unsigned char)([rgbChannel1 blueComponent] * 255);
+ message.colors[0] = (unsigned char)([rgbChannel1 greenComponent] * 255);
+ message.colors[1] = (unsigned char)([rgbChannel1 blueComponent] * 255);
+ message.colors[2] = (unsigned char)([rgbChannel1 redComponent] * 255);
- message.colors[3] = (unsigned char)([rgbChannel2 redComponent] * 255);
- message.colors[4] = (unsigned char)([rgbChannel2 greenComponent] * 255);
- message.colors[5] = (unsigned char)([rgbChannel2 blueComponent] * 255);
+ message.colors[3] = (unsigned char)([rgbChannel2 greenComponent] * 255);
+ message.colors[4] = (unsigned char)([rgbChannel2 blueComponent] * 255);
+ message.colors[5] = (unsigned char)([rgbChannel2 redComponent] * 255);
- message.colors[6] = (unsigned char)([rgbChannel3 redComponent] * 255);
- message.colors[7] = (unsigned char)([rgbChannel3 greenComponent] * 255);
- message.colors[8] = (unsigned char)([rgbChannel3 blueComponent] * 255);
+ message.colors[6] = (unsigned char)([rgbChannel3 greenComponent] * 255);
+ message.colors[7] = (unsigned char)([rgbChannel3 blueComponent] * 255);
+ message.colors[8] = (unsigned char)([rgbChannel3 redComponent] * 255);
- message.colors[9] = (unsigned char)([rgbChannel4 redComponent] * 255);
- message.colors[10] = (unsigned char)([rgbChannel4 greenComponent] * 255);
- message.colors[11] = (unsigned char)([rgbChannel4 blueComponent] * 255);
+ message.colors[9] = (unsigned char)([rgbChannel4 greenComponent] * 255);
+ message.colors[10] = (unsigned char)([rgbChannel4 blueComponent] * 255);
+ message.colors[11] = (unsigned char)([rgbChannel4 redComponent] * 255);
unsigned char checksum = 0;
for (int i = 0; i < sizeof(message.colors); i++)

0 comments on commit 45c6c2a

Please sign in to comment.