Project showcase
Cylon Raider!

Cylon Raider! © GPL3+

This is my Clyon Raider kit to which I added Arduino controlled internal lighting.

  • 7 views
  • 0 comments
  • 0 respects

Components and supplies

About this project

Decided to build a model after 55+ years. Found a Moebius (brand) model of a new style Cylon Raider at an amazing hobby shop in Seattle (Skyway Models) when we were visiting our son. When I started the build I decided to illuminate it. After research decided a nano would be the best route. So after spending easily 5 times what the model cost on electronic bits, fiber optics, paint, glue, etc., I finally finished during week 2 of our COVID isolation; we don't have it but we don't want to get it!

If you are interested, I have put some photos and two short videos here:

https://photos.app.goo.gl/hAKMXueuW2D4TRGD7

Code

LED driver code for Cylon RaiderActionScript
This drives the "Cylon lights" in the cockpit and randomly illuminates the guns. Written by larryd on this forum.
//******************************************************************************
//
//                     YY/MM/DD
// Version     1.03    20/01/26
//
//
//******************************************************************************

const byte pinArray[]               = {2, 3, 4, 5, 6, 7};
const byte ledPin                   = 8;

byte timingState;
byte ledPinFlag;

int count;

unsigned long randOnLocked;
unsigned long randOffLocked;

const unsigned long timerInterval   = 55;
unsigned long interval = timerInterval * 2;
unsigned long commonTimerMillis;
unsigned long ledPinMillis;

//******************************************************************************
void setup()
{
  randomSeed(analogRead(0));  //randomize

  pinMode(ledPin, OUTPUT);    //set pin 8 as output

  //************************************
  for (count = 0; count < 6; count++)
  {
    pinMode(pinArray[count], OUTPUT);
  }

  count = 0;
  commonTimerMillis = millis() - interval;

} //END of setup()

//******************************************************************************
void loop()
{
  //************************************
  if (ledPinFlag == 0)
  {
    randOnLocked  = random (1050, 3000);
    randOffLocked = random (2000, 9000);
   
    digitalWrite(ledPin, HIGH);

    ledPinFlag = 1;
    ledPinMillis = millis();
  }

  if (ledPinFlag == 1 && millis() - ledPinMillis > randOnLocked)
  {
    digitalWrite(ledPin, LOW);

    ledPinFlag = 2;
    ledPinMillis = millis();
  }

  if (ledPinFlag == 2 && millis() - ledPinMillis > randOffLocked)
  {
    //start again
    ledPinFlag = 0;
  }

  //************************************
  //check the machine statae
  checkMachine();
 
  //************************************
  //other non blocking code goes here
  //************************************

} //END of loop()


//******************************************************************************
bool checkTimer()
{
  if (millis() - commonTimerMillis >= interval)
  {

    commonTimerMillis = millis();
    return true;
  }

  return false;

} //END of checkTimer()


//******************************************************************************
void checkMachine()
{
    switch (timingState)
  {
    //*************************
    //DOWN
    case 0:
      if (checkTimer() == true)
      {
        digitalWrite(pinArray[count], HIGH);

        interval = timerInterval;
        timingState = 1;
      }

      break;

    //*********
    case 1:
      if (checkTimer() == true)
      {
        digitalWrite(pinArray[count + 1], HIGH);

        interval = timerInterval;
        timingState = 2;
      }

      break;

    //*********
    case 2:
      if (checkTimer() == true)
      {
        digitalWrite(pinArray[count], LOW);

        interval = timerInterval * 2;

        count++;
        if (count >= 5)
        {
          timingState = 5;
        }

        else
        {
          timingState = 0;
        }

      }

      break;

    //*************************
    //UP
    case 5:
      if (checkTimer() == true)
      {
        digitalWrite(pinArray[count], HIGH);

        interval = timerInterval;
        timingState = 6;
      }

      break;

    //*********
    case 6:
      if (checkTimer() == true)
      {
        digitalWrite(pinArray[count - 1], HIGH);

        interval = timerInterval;
        timingState = 7;
      }

      break;

    //*********
    case 7:
      if (checkTimer() == true)
      {
        digitalWrite(pinArray[count], LOW);

        interval = timerInterval * 2;

        count--;
        if (count <= 0)
        {
          timingState = 0;
        }

        else
        {
          timingState = 5;
        }

      }

      break;

  } //END of switch/case

} //END of checkMachine()

//******************************************************************************

Schematics

Arduino Nano Every Led Driver
Used to drive LEDs in model kit
Driver bcccaar4lf

Comments

Author

Default
steveQlQ
  • 1 project
  • 0 followers

Additional contributors

  • Graciously writing code using millis to get all the leds to play nicely together! by larryd

Published on

March 27, 2020
See similar projects
you might like

Similar projects you might like

LED Dice

Project showcase by Team ONYX

  • 11,611 views
  • 1 comment
  • 19 respects

Lightning Cloud

Project showcase by lebo

  • 3,520 views
  • 5 comments
  • 8 respects

Buzz Wire with Score Counter

Project tutorial by behrooz66

  • 9,738 views
  • 26 comments
  • 42 respects

Build the Ultimate Dry Ice Machine

Project tutorial by lewiseab

  • 9,434 views
  • 1 comment
  • 24 respects

RCar | Robots for All!

Project tutorial by Luís Rita

  • 8,569 views
  • 2 comments
  • 42 respects

Digital Windmill "Digindmill"

Project tutorial by HomeMadeGarbage

  • 8,874 views
  • 1 comment
  • 26 respects
Add projectSign up / Login