Room-lightning ( hackaday contest )

We (my dad and I, aka mclien -slightly older than 42- and sisam -14- ) just implemented an easteregg in another project in our house, which is still WiP and not (yet) documented itself.
It's mainly the lightning of sisams room, which is based on a arduino mega with a shifty vu shield, an oktobar and several Satellite s-001 modules from macetech.
These are installed into self-sculptured, wall integrated lampshades. (see below)

To control it we build a custom hardware mixer:
hardware part are planned by mclien, assembly we did together and software is done nearly only by sisam)

  • 1) activate/deactivate switches for each lamp
  • 2) slide resistors for each color (1024 steps)
  • 3) LCD Panel shows the selected Program mode (one for now)
  • 4) torque switch for selecting program mode
  • 5) push buttons for store/invoke stored setups (to be implemented)

The torque switch is to select different programs/setups (which, as you guess) aren't implemented yet. But the running part is the shown program part (called RGB colormix), which allows to control each RGB channel with one of the slide resistor.
The left row of switches are used to (de-)activate each of the lamps. Every deactivated lamp stays in the last state of colormix.
For the contest we implemented the following easteregg:

When the color is set to the same color hackaday uses for the lettering the LCD writing changes from "RGB colomix" to the hackaday url.
Here is the success, when the user has managed to get the r and b slider in position zero and the green one in position, that represent #00c100 (with ~0.4% tolerance)
ALL other positions of the slider show "RGB colormix in the display

Link to the video at vimeo (sorry for the quality. We only had our old canaon powershot digicam to do it):
here

code below (improvments happily appreciated):

#include

#include

LiquidCrystal lcd(48, 49, 22, 23, 24, 25);



// Defines for use with Arduino functions
#define clockpin 13 // CI
#define enablepin 10 // EI
#define latchpin 9 // LI
#define datapin 11 // DI

// Defines for direct port access
#define CLKPORT PORTB
#define ENAPORT PORTB
#define LATPORT PORTH
#define DATPORT PORTB
#define CLKPIN 7
#define ENAPIN 4
#define LATPIN 6
#define DATPIN 5

// Variables for communication
unsigned long SB_CommandPacket;
int SB_CommandMode;
int SB_BlueCommand;
int SB_RedCommand;
int SB_GreenCommand;

// Define number of ShiftBrite modules
#define NumLEDs 8

// Create LED value storage array
int LEDChannels[NumLEDs][3] = {0};

int kippschalter[9] = {35, 36, 37, 38, 39, 40, 41, 42, 43};
int Speichertaster_1 = 33;
int Speichertaster_2 = 32;
int Speichertaster_3 = 31;
int Speichertaster_4 = 30;
int Speichertaster_5 = 29;
int Speichertaster_6 = 28;
int Speichertaster_7 = 27;
int Speichertaster_8 = 26;
int ledPinR = 5;
int ledPinB = 6;
int ledPinG = 7;
int potiePinR = A13;
int potiePinB = A14;
int potiePinG = A15;
int potieStateR = 0;
int potieStateB = 0;
int potieStateG = 0;
int kippschalterState = 0;
int lcdlight = 2;

// Set pins to outputs and initial states
void setup() {

for (int a = 0; a <= 9; a += 1){
pinMode(kippschalter[a], INPUT);
}
pinMode(Speichertaster_1, INPUT);
pinMode(Speichertaster_2, INPUT);
pinMode(Speichertaster_3, INPUT);
pinMode(Speichertaster_4, INPUT);
pinMode(Speichertaster_5, INPUT);
pinMode(Speichertaster_6, INPUT);
pinMode(Speichertaster_7, INPUT);
pinMode(Speichertaster_8, INPUT);
pinMode(ledPinB, OUTPUT);
pinMode(ledPinR, OUTPUT);
pinMode(ledPinG, OUTPUT);
pinMode(potiePinB, INPUT);
pinMode(potiePinR, INPUT);
pinMode(potiePinG, INPUT);
pinMode(lcdlight, OUTPUT);

pinMode(datapin, OUTPUT);
pinMode(latchpin, OUTPUT);
pinMode(enablepin, OUTPUT);
pinMode(clockpin, OUTPUT);
digitalWrite(latchpin, LOW);
digitalWrite(enablepin, LOW);
analogWrite(ledPinR, 50);
analogWrite(ledPinB, 10);
analogWrite(ledPinG, 70);

digitalWrite(26, HIGH);
digitalWrite(27, HIGH);
digitalWrite(28, HIGH);
digitalWrite(29, HIGH);
digitalWrite(30, HIGH);
digitalWrite(31, HIGH);
digitalWrite(32, HIGH);
digitalWrite(33, HIGH);

digitalWrite(35, HIGH);
digitalWrite(36, HIGH);
digitalWrite(37, HIGH);
digitalWrite(38, HIGH);
digitalWrite(39, HIGH);
digitalWrite(40, HIGH);
digitalWrite(41, HIGH);
digitalWrite(42, HIGH);
digitalWrite(43, HIGH);

analogWrite(lcdlight, 100);

lcd.begin(8, 2);
lcd.print(" RGB co");
lcd.setCursor(0,1);
lcd.print("lormix ");

Serial.begin(9600);
}

void SB_SendPacket() {

if (SB_CommandMode == B01) {
SB_RedCommand = 127;
SB_GreenCommand = 110;
SB_BlueCommand = 110;
}

SB_CommandPacket = SB_CommandMode & B11;
SB_CommandPacket = (SB_CommandPacket << 10) | (SB_BlueCommand & 1023);
SB_CommandPacket = (SB_CommandPacket << 10) | (SB_RedCommand & 1023);
SB_CommandPacket = (SB_CommandPacket << 10) | (SB_GreenCommand & 1023);

for (int j = 0; j < 32; j++) {
if ((SB_CommandPacket >> (31 - j)) & 1) {
DATPORT |= (1 << DATPIN);
}
else {
DATPORT &= ~(1 << DATPIN);
}
CLKPORT |= (1 << CLKPIN);
CLKPORT &= ~(1 << CLKPIN);
}
}

void SB_Latch() {

delayMicroseconds(1);
LATPORT |= (1 << LATPIN);
ENAPORT |= (1 << ENAPIN);
delayMicroseconds(1);
ENAPORT &= ~(1 << ENAPIN);
LATPORT &= ~(1 << LATPIN);

}

void WriteLEDArray() {

SB_CommandMode = B00; // Write to PWM control registers

for (int i = 0; i < NumLEDs; i++) {
SB_RedCommand = LEDChannels[i][0];
SB_GreenCommand = LEDChannels[i][1];
SB_BlueCommand = LEDChannels[i][2];
SB_SendPacket();
}

SB_Latch();

SB_CommandMode = B01; // Write to current control registers

for (int z = 0; z < NumLEDs; z++) SB_SendPacket();

SB_Latch();

}



void loop() {

potieStateR = analogRead(potiePinR);
potieStateG = analogRead(potiePinG);
potieStateB = analogRead(potiePinB);

if (potieStateG > 768 and potieStateG < 776 and potieStateR == 0 and potieStateB == 0) {
lcd.begin(8, 2);
lcd.setCursor(0,0);
lcd.print(" hackad");
lcd.setCursor(0,1);
lcd.print("ay.com ");
}
else {
lcd.begin(8, 2);
lcd.setCursor(0,0);
lcd.print(" RGB co");
lcd.setCursor(0,1);
lcd.print("lormix ");
}

for (int channel = 0; channel < 9; channel+= 1) {
kippschalterState = digitalRead(kippschalter[channel]);
if (kippschalterState == LOW) {
LEDChannels[channel][0] = potieStateR;
LEDChannels[channel][1] = potieStateG;
LEDChannels[channel][2] = potieStateB;
}
WriteLEDArray();
}
}

wiring of the arduino (sorry, just a german spreadsheet, because of time limits)




Shifty shield Ethershield LCD Display Mischpult
analog digital
extern stacked extern



AREF






IOREF






RESET






GND X X X X


Vin






5 V X X X X


3.3 V





0






1






2 PWM

light on/off
ggf. Helligkeit über PWM

3 PWM



Ggf. 2.Farbe für RGB Display

4 PWM
Sdcard sel.



5 PWM


Schieber LED R Ggf. 3.Farbe für RGB Display

6 PWM


Schieber LED B

7 PWM


Schieber LED G

8 PWM





9 PWM LI


Oktobar /Shiftbar

10 PWM EI WIZ chip sel.

Oktobar /Shiftbar

11 PWM DI


Oktobar /Shiftbar

12 PWM





13 PWM CI


Oktobar /Shiftbar

14






15



Wahlschalter Funktion 1 Kabelfarbe schwarz

16



Wahlschalter Funktion 2 Kabelfarbe rot

17



Wahlschalter Funktion 3 Kabelfarbe braun

18



Wahlschalter Funktion 4 Kabelfarbe orange

19



Wahlschalter Funktion 5 Kabelfarbe grün

20



Wahlschalter Funktion 6 Kabelfarbe rosa

21






22


DB4/P11
wirklich kein PWM?, sonst PIN 5

23


DB5/P12
kein PWM -> default belegung CrystalLib

24


DB6/P13
wirklich kein PWM?, sonst PIN 7

25


DB7/P14
kein PWM -> ladyada Tutorial

26



Speichertaster 8 Kabelfarbe grün

27



Speichertaster 7 Kabelfarbe rot

28



Speichertaster 6 Kabelfarbe braun

29



Speichertaster 5 Kabelfarbe violet

30



Speichertaster 4 Kabelfarbe grau

31



Speichertaster 3 Kabelfarbe gelb

32



Speichertaster 2 Kabelfarbe blau

33



Speichertaster 1 Kabelfarbe orange

34




res. Für weitere Lampe...

35



Kippschalter Lampe 1 Kabelfarbe blau

36



Kippschalter Lampe 2 Kabelfarbe orange

37



Kippschalter Lampe 3 Kabelfarbe türkies

38



Kippschalter Lampe 4 Kabelfarbe violet

39



Kippschalter Lampe 5 Kabelfarbe grün

40



Kippschalter Lampe 6 Kabelfarbe weiß

41



Kippschalter Lampe 7 Kabelfarbe rosa

42



Kippschalter Lampe 8 Kabelfarbe rot

43



Kippschalter Lampe 9 Kabelfarbe gelb

44






45






46






47






48


RS/P4
kein PWM -> ladyada Tutorial

49


EN/P6
kein PWM -> ladyada Tutorial

50 SPI
eth/sd



51 SPI
eth/sd



52 SPI
eth/sd



53 SPI
ss output


0






1






2

filtered audio



3

filtered audio



4






5






6





Verdeckt von Shifty shield
7






8






9






10






11






12






13




Schieber 1 R provesorisch: Pin a3
14




Schieber 2 B provesorisch: Pin a4
15




Schieber 3 G provesorisch: Pin a5

(the english bad writing is from mclien)