Scott Penrose

Rainbow House 5

Scott is an expert software developer with over 30 years experience, specialising in education, automation and remote data.

Rainbow House 3 is dead, Rainbow House 4 not complete, long live Rainbow House 5...

My linux box running my house was built in the late 90s and has been running my house very nicely for the past 12 years. Unfortunately today it developed a hard disk error - yes the box is still fine, just the disk failed. But I didn't really have a proper backup. I have all the content to rebuild it... just not the time.

So I grabbed a Freetronics Ethermega and built a replacement in a couple of hours. Nothing like need to drive a new version.


I have been building a replacement for 2 or more years. Just never get around to finishing it. The replacement I have been building has multiple output drivers (hardware pins, latches of various types, remote calls via ethernet, etc); multiple inputs (hardware buttons, PS2 keyboard, ethernet including web interface); business rules (automatic shutdown, dependents, lots more)... All up about 3000 lines.


The thing is that I keep thinking of a new thing to do or something else to try before I finish... so now the brief version.

How do I replace the existing Linux based system with no hardware changes.

  • Business rules - these can be simplified, e.g. just toggle lights with buttons, rest can come later
  • PS2 Keyboard - I use PS2 keyboard as an extremely easy way to get lots of inputs. Very handy, keeps things isolated etc...
  • Parallel Port latched relay control card - ok... how to do this?

Business Rules

Easy... just swap a bit specified - swap(data1, 3) - will swap status of a bit stored in a data byte.

void swap(byte &a, byte b) {
  if (bitRead(a, b))
    bitClear(a, b);
    bitSet(a, b);

PS2 Keyboard


  PS2Keyboard keyboard;
  keyboard.begin(PS2_DATA, PS2_IRQ);
  if (keyboard.available()) {
    char c =;
    ... do something with c ...

Parallel Port Latched relay controller

OK This one was a little harder. Due to the HUGE number of pins on a Mega, I won't bother with any form of latch/multiplexer for now. But that means having some form of relay driver (e.g. FET). That however requires change of hardware.

I want to walk down to my plant room, unplug the linux box, and plug in my Arduino.

Parallel ports are just digital writes. Should be simple enough:

  digitalWrite(38, HIGH);
  digitalWrite(39, LOW);
  digitalWrite(40, HIGH);
  digitalWrite(41, LOW);

  // Copy byte 1
  PORTC = save_1;

  digitalWrite(41, HIGH);
  digitalWrite(41, LOW);

The trick is to set the board id (38, 39, 40) and the write the byte, clocking it out (latching it).


I managed to write the code, get it tested on a separate test bed and write this web page in 2 hours. That said, I have not actually plugged it into my house as it is too late tonight.

Don't be afraid just to throw yourself in the deep end when trying something.

Just do it... I have procrastinated for years on this, it it only took a couple of hours, why didn't I do it 2 years ago. Sometimes that emergency situation is what is required.

Dumb down your requirements. Better to have something working (this code is 200 lines with lots of comments on parallel ports etc), than perfect or feature full.

  • Arduino