logo fantastic modelers logo fantastic modelers logo fantastic modelers
SF and fantastic models
bouton orange bouton bleu contour bouton

Imperial Star Destroyer (2) :
Arduino card in scale modeling

Arduino chip used to realize the light-up of an imperial stardestroyer Star Wars.

A few weeks ago I began to make an Star Wars imperial star destroyer. I decided to educate my self on the Arduino cards. These cards allow to upload a program wich runs automatically as soon as the card is powered. I won’t explain here the all card operation ; if you’re interested you can go directly on the Arduino website. I just want to show you what you can do with an Arduino in your models.

Thrusters ignition

The most interesting aspect of an Arduino card on a model is the thrusters ignition. Your only limit is your imagination. You can program a gradual, out of sync, at all speeds ignition. On this model, I added a random noise, as if the thrusters have a temporary malfunction at ignition.

Maneuver thrusters ignition on request

Maneuver thrusters, the four small thrusters flanking the three big ones at the rear can be ignited on request by using a puch-button attached on the base stand.

Imperial Stardestroyer : maneuver thrusters off
Imperial Stardestroyer : manouver thrusters on

You can see the ignition sequence in the video above.

Power on in sequence

A very cool effect when powering on a model : the different sections are turned on in sequence, that is, not at the same time. When I finish the model, I’ll put a video of the entire sequence online.

Random light up for the portholes

On such a huge starship, there is no good reason that all the portholes are enlighted at the same time. As I used an Arduino card, I took advantage to program a random light up for the portholes. Every time you power the model on, the program choose a random light up pattern. Thus, from one time to another, different portholes are enlighted.

Stardestroyer portholes' lightup - second pattern

Stardestroyer portholes' lightup - first pattern

These two pictures show two different light up patterns. Enjoy the 7 differences game…

The code

As Arduino is open source, I wanted to keep the spirit by giving you the code I wrote to make this scale model. Don’t hesitate to ask me some questions if you want to use it. As Arduino is open source, I wanted to keep the spirit by giving you the code I wrote to make this scale model. Don’t hesitate to ask me some questions if you want to use it.



void setup() {
  
Serial.begin(9600);

// réacteurs principaux
  pinMode(9,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(11,OUTPUT);

// réacteurs de manoeuvre
  pinMode(5,OUTPUT);

// bouton poussoir
  pinMode(2,INPUT_PULLUP);//le poussoir est connecté entre la terre et l'entrée via une résistance pull_up de 20 kOhm interne, attention le pin est par défaut à l'état HIGH, LOW si poussoir enfoncé

//hublots
  pinMode(7,OUTPUT);
  pinMode(8,OUTPUT);
  pinMode(12,OUTPUT);

  randomSeed(analogRead(0));
  int tirage = random(0,10);//tirage d'un nombre aléatoire pour allumer les hublots suivants des schémas différents
  
  randomSeed(analogRead(0));
  int delai_1=random(100,600);

  randomSeed(analogRead(0));
  int delai_2=random(100,600);


  switch(tirage){
    case 0:
        digitalWrite(7,HIGH);
        delay(delai_1);
        digitalWrite(8,HIGH);
        delay(delai_2);
        digitalWrite(12,HIGH);
    break;

    case 1:
        digitalWrite(7,LOW);
        delay(delai_1);
        digitalWrite(8,LOW);
        delay(delai_2);
        digitalWrite(12,HIGH);
    break;

    case 2:
        digitalWrite(7,LOW);
        delay(delai_1);
        digitalWrite(8,HIGH);
        delay(delai_2);
        digitalWrite(12,LOW);
    break;

    case 3:
        digitalWrite(7,HIGH);
        delay(delai_1);
        digitalWrite(8,LOW);
        delay(delai_2);
        digitalWrite(12,LOW);
    break;

    case 4:
    case 5:
        digitalWrite(7,HIGH);
        delay(delai_1);
        digitalWrite(8,HIGH);
        delay(delai_2);
        digitalWrite(12,LOW);
    break;

    case 6:
    case 7:
        digitalWrite(7,HIGH);
        delay(delai_1);
        digitalWrite(8,LOW);
        delay(delai_2);
        digitalWrite(12,HIGH);
    break;
    
    case 8:
    case 9:
        digitalWrite(7,LOW);
        delay(delai_1);
        digitalWrite(8,HIGH);
        delay(delai_2);
        digitalWrite(12,HIGH);
    break;
  }

//éclairage hangar
  pinMode(3,OUTPUT);

  delay(2000);
  digitalWrite(3,HIGH);

//éclairage LED CMS latérales  
  
  pinMode(4,OUTPUT);

  delay(4000);
  digitalWrite(4,HIGH);
  
}

int i[14];//initialisation des compteurs utiliés dans chaque fonction réacteur
bool etatAllumage = 0;
int j=1;//intialisation du compteur pour les réacteurs de maneouvre

  void loop() {
        reacteur(9,9000,15200,true);
        reacteur(10,5000,15000,true);
        reacteur(11,7000,15600,true);

   if(etatAllumage==1){

      while(j<=255){//allumage des réacteurs
        if(j<0){//après le premier passage, j vaut -1 et allume la LED, on le ramène à zéro pour éviter le flash initial
          j=0;
        }
        analogWrite(5,j);
        delay(10);
        j++;
      }
    }
    
    else{//extinction des réacteurs
        while(j>=0){
        analogWrite(5,j);
        delay(1);
        j--;
      }
    }
           
    bool etatPinPoussoir = digitalRead(2);
    delay(5);
    if(!etatPinPoussoir){
      if(etatAllumage){
        etatAllumage = 0;
        
      }
      else{
        etatAllumage = 1;
      }
    }

}

void reacteur(int pin,unsigned long dureeAllumage, unsigned long delai,bool bruitOn){

    float pas = dureeAllumage/255;//calcul du pas temporel
    unsigned long currentMillis = millis();

    static unsigned long previousMillis[14];//un tableau de valeurs est initialisé (les variables en static ne doivent pas interférer entre les différents appels de la fonction)

      if(currentMillis<(dureeAllumage+delai)){

        if((currentMillis-previousMillis[pin])>=pas && (currentMillis>delai)){//si la date est inférieure à la durée d'allumage paramétrée
          previousMillis[pin] = currentMillis;//la date actuelle est sauvegardée pour servir de référence pour la prochaine boucle
          analogWrite(pin,i[pin]);//la LED est alluméeà i[pin]/255 du maximum
          i[pin] = i[pin]+1;//le compteur est incrémentée pour la prochaine boucle

          if(bruitOn){
          
          randomSeed(analogRead(0));//initialisation de la fonction random en lisant l'entrée 0 qui du coup doit rester non connectée
          int bruit = random(0,100);

             if(bruit<8){
              digitalWrite(pin,LOW);
              delay(10);
              analogWrite(pin,i[pin]);
             }
          }

        if(i[pin]>=255){
          digitalWrite(pin,HIGH);//si le maximum est atteint, la LED reste allumée
        }
      }
   }      
}

It seems to be a huge code to make very few actions but it’s unavoidable when you code…

Inserting the card into the base stand

A newbie mistake (that I often made) consist of inserting the electronic card into the model itself. Tempting : only 2 or 3 wires to pass through the support rod and you can make a smaller base stand.

Unfortunately, it does not allow to take care of the card. Many problems can occur during the model’s life : code failure if the card is misplaced in a magnetic field, card aging, electrical contacts aging etc. It’s wiser to plan for the worst and anticipate a further card replacement.

Arduino card on a scale model insertion, into the model's base

That’s why I inserted the card into the base stand. Obviously, the inconvenience is that I had to pass 12 wires through the support rod… but they went through at the end.

Conclusion : benefits of using an Arduino card on a model

It took me years to make the final leap. It’s always the same with novelty. You think “that’s ok, it works like that why change ?”. I decided to do so during the assemply of the USS Enterprise NCC-1701-A I made last year.

My client asked me to use a commercial lighting kit wich allowed position lamps to blink, gradual ignition of the thrusters etc. At that time, I wondered if I could do it by myself and decided that I’ll do it for my next model.

On this imperial star destroyer model, only the light is to be operated but there are many other possibilities : electrical engines to animate some parts, sounf effects, different light up patterns at the operator’s choice etc. I always keep in mind the Hoth echo base hangar animated, lighted up and with a sound system… in some other life, I fear !

Posted on 25 August 2019 by petersteven in Work in progress

bouton orange bouton bleu contour bouton

Leave a comment ?




This site uses Akismet to reduce spam. Learn how your comment data is processed.