The Illumination of The Nautilus

An old friend of mine has a model of Jules Verne's Nautilus in the grips of a giant squid that he always talks about how he wishes it were illuminated but never had the ability. I thought a great 75th birthday present for him (and a challenging intro to the world of Arduino for me) would be to use an Arduino Nano and some LEDs to provide a couple of animated lighting effects.

He sees the exterior as having a shimmering blue/green underwater look while the interior gives the appearance of an unseen person moving around from room to room and back, carrying a lantern.

I thought it would be an added bonus to also make the interior flash red at the push of a button to simulate an emergency alarm.

My goal was to accomplish the following events by pressing pressing a button 1 to 3 times:
1st press - Turn on water shimmer and invisible lantern carrier effects
2nd press - Replace invisible lantern carrier effect with red emergency lighting
3rd press - Turn off all lighting

For the water effect I thought of using a slightly modified version of some code I found on this site under the topic, "Fading multiple LEDs at Different Rates" response #5

For the invisible lantern carrier effect, I thought of modifying an LED chase to slow down and fade the LEDs. I haven't found that code yet.

I also still don't quite understand how to combine all three push button phases in a single sketch

This project has not had the attention it deserves from me and although I started researching about two months ago, I work 12+ hrs/day and 5 to 7 days/wk, which hasn't left me enough time to spend on it and his birthday is approaching too rapidly (May 29th).

I either need find help compiling the code or, sadly, hang my head and admit defeat. I'm desperately hoping to avoid the latter.

Either way, I appreciate all the information this site provides as well as all those who have contributed their knowledge.

hk1972:
An old friend of mine has a model of Jules Verne's Nautilus in the grips of a giant squid that he always talks about how he wishes it were illuminated but never had the ability. I thought a great 75th birthday present for him (and a challenging intro to the world of Arduino for me) would be to use an Arduino Nano and some LEDs to provide a couple of animated lighting effects.

He sees the exterior as having a shimmering blue/green underwater look while the interior gives the appearance of an unseen person moving around from room to room and back, carrying a lantern.

I thought it would be an added bonus to also make the interior flash red at the push of a button to simulate an emergency alarm.

My goal was to accomplish the following events by pressing pressing a button 1 to 3 times:
1st press - Turn on water shimmer and invisible lantern carrier effects
2nd press - Replace invisible lantern carrier effect with red emergency lighting
3rd press - Turn off all lighting

For the water effect I thought of using a slightly modified version of some code I found on this site under the topic, "Fading multiple LEDs at Different Rates" response #5

For the invisible lantern carrier effect, I thought of modifying an LED chase to slow down and fade the LEDs. I haven't found that code yet.

I also still don't quite understand how to combine all three push button phases in a single sketch

This project has not had the attention it deserves from me and although I started researching about two months ago, I work 12+ hrs/day and 5 to 7 days/wk, which hasn't left me enough time to spend on it and his birthday is approaching too rapidly (May 29th).

I either need find help compiling the code or, sadly, hang my head and admit defeat. I'm desperately hoping to avoid the latter.

Either way, I appreciate all the information this site provides as well as all those who have contributed their knowledge.

I would highly recomend that you get a hundred cheap LED's to paractic with.
check out CrossRoads web for this device
MAX7219 daisychainable breakout board

http://www.crossroadsfencing.com/BobuinoRev17/

not quite 2/3 of the way down

if you can get a couple LED's to turn on and off in your patterns, things would make more sense for you.

as for the chase of lights, that is not that hard, but you have to have the LED's with quantities.

I do not completly follow your needs, but if you were to look at a model house, you could have an LED light up one room, fade up, then down, and while it is fading down, the next room is fading up, then as that fades down, the light on the stairs fades up and ....... that would make it looks like someone with a candle or lantern is walking the halls.

you did not mention the size of the model. size is key as a huge LED might not fit and a grain of sand LED might not offer enough light.

as for the buttons, that is the easiest part.

what Arduino do you have to start with ?

This sounds like a GREAT first(ish) project! Yes, it is very doable with beginner-to-intermediate Arduino skills. I agree with dave that you will need some LEDs to practice with. Also get some resistors: 75 ohm for very bright, 330 ohm for medium bright, and1K ohm for dim, but noticeable (these are approximate values.) Get some way of hooking things together. A breadboard is great for experimenting, but to put your 'lighting harness' together, learn (or recall) how to solder. Look at the nano and micro boards - they both have lots of pins, yet are small enough to hide inside a model - and they program through the USB port.

Thanks for the replies.

The model is not very large, with overall dimensions of roughly a foot long by 3-4 inches wide and about 8 inches tall. The Nautilus’ interior has a rather small viewable area at around 3" x 3" x 4".

I have several 50 resistor packs in a wide range of values, more than enough blue and green LEDs from a starter Arduino kit that I’m using for the water, and as far as the effect of walking around the ship with a candle/lantern, I plan on using some of the MANY small LEDs I’ve harvested from broken LCD displays. (The harvested LEDs are mainly to satisfy George’s desire to re-purpose anything he can keep out of a land fill)

I’m also using breadboards for the prototyping and will eventually upload the completed sketch to one of the Nano boards I bought.

The physical assembly (including soldering) is much more familiar to me than the coding part. I have assembled a variety of electronics kits over the past few years, but nothing needing programming until now.

After a HUGE ‘Thank You’ to johnwasser, here is the code I have so far, modified, by trial and error, to serve as the underwater look:

const int CHANNELS = 6;

const int LED_PINS[CHANNELS] = {3, 5, 6, 9, 10, 11};

// Note: There is no speed penalty to use multiply or divide in compile-time constants since the
// math is done by the compiler, not the microprocessor.
// Note: To avoid overflow warnings, constants that, multiplied together, won't fit in a signed integer 
// had to be marked "unsigned"
const unsigned int MIN_BRIGHTNESS[CHANNELS] = {3*256, 5*256, 10*256, 15*256, 10*256, 5*257};
const unsigned int MAX_BRIGHTNESS[CHANNELS] = {205U*256U, 103U*256U, 180U*256U, 210U*256U, 200U*256U, 240U*256U};

unsigned int CurrentBrightness[CHANNELS] =  {175U*256U, 60*256, 120*256, 100*256, 75*256, 200U*256U};
int FadeAmount[CHANNELS] = {19, 20, 22, 25, 23, 21};  // Slow the fades down by a factor of 85

// the setup routine runs once when you press reset:
void setup() {
  for (int i = 0; i < CHANNELS; i++) {
    pinMode(LED_PINS[i], OUTPUT);
  }
}

// the loop routine runs over and over again forever:
void loop() {
  for (int i = 0; i < CHANNELS; i++) {
    analogWrite(LED_PINS[i], CurrentBrightness[i]>>8);

    CurrentBrightness[i] += FadeAmount[i];

    // reverse the direction of the fading at the ends of the fade:
    if (CurrentBrightness[i] <= MIN_BRIGHTNESS[i] ||
        CurrentBrightness[i] >= MAX_BRIGHTNESS[i]) {
      FadeAmount[i] = -FadeAmount[i];
    }
  }

  // wait for one milliseconds to see the dimming effect
  delay(1);  // Speed the fades up by a factor of 90
}

HI,
A model something like these;
18b859d9f6771c669efcf28cc7668aa5 (1).jpgnautilus-2.jpg

Tom… :slight_smile:

hk1972:
I also still don't quite understand how to combine all three push button phases in a single sketch

You need a finite state machine for that. Each button press (there are libraries that take care of debouncing for you) moves the code in the next state.

This project has not had the attention it deserves from me and although I started researching about two months ago, I work 12+ hrs/day and 5 to 7 days/wk, which hasn't left me enough time to spend on it and his birthday is approaching too rapidly (May 29th).

Gonna be tough... very tough... Do you have the LEDs wired up already?

For the state machine, it'll look a bit like this:

#define S_OFF 0; // Turn off all lighting
#define S_SHIMMER 1; //Turn on water shimmer and invisible lantern carrier effects
#define S_EMERGENCY 2; // Replace invisible lantern carrier effect with red emergency lighting

byte programState = 0;

void loop() {

  // Move through states upon button presses.
  if (buttonPress()) {
    programState++;
    allOff();
    if (programState > 2) {
      programState = 2;
    }
  }
  

  // Operate lights based on the state we're in.
  switch (programState) {
    case S_OFF:
      break;

    case S_SHIMMER:
      shimmer();
      break;

    case S_EMERGENCY:
      emergency();
      break;
  }
}

Adding different patterns becomes trivial this way - just add another state in the switch list, add the function that does the LED handling, and you're done. The LED handling in your loop() becomes one of those functions - it will be called upon every run of loop(), not just when the state changes. Make sure to return quickly from those functions or your button is not responsive.

I put the allOff() function to the button press part, this should switch off everything the moment the button is pressed (and the state changes) so you have a known state to start from. So also when you're in the S_OFF state, just don't do anything.