Building my own x-wing

Discussion in 'Science Fiction & Fantasy' started by dnalor, Apr 18, 2012.

  1. dnalor

    dnalor Active Member

    Joined:
    Oct 28, 2011
    Messages:
    928
    Likes Received:
    183
    Ok..
    After asking my friend Google :) i found this sketch.
    It does almost everything what i want

    The cockpit changes RGB..
    A nice engine flicker.

    i only need a steady light insert in it...that i'm working on..
    But i also have an error in it.and didn't find the solution...(i still have to search)


    Maybe somebody has the fix for the error?


    int red = 11; //this sets the red led pin
    int green = 10; //this sets the green led pin
    int blue = 9; //this sets the blue led pin
    int flickerLED = 8; // flicker on pin 8

    int redNow;
    int blueNow;
    int greenNow;
    int redNew;
    int blueNew;
    int greenNew;
    int flickertime;

    void setup()
    { //this sets the output pins
    pinMode(red, OUTPUT);
    pinMode(green, OUTPUT);
    pinMode(blue, OUTPUT);
    pinMode(flickerLED,OUTPUT);
    redNow = random(255);
    blueNow = random(255);
    greenNow = random(255);
    redNew = redNow;
    blueNew = blueNow;
    greenNew = greenNow;
    }

    #define fade(x,y) if (x>y) x--; else if (x
    void loop()
    {
    analogWrite(blue, blueNow);
    analogWrite(red, redNow);
    analogWrite(green, greenNow);
    redNew = random(255);
    blueNew = random(255);
    greenNew = random(255);
    // fade to new colors
    while ((redNow != redNew) ||
    (blueNow != blueNew) ||
    (greenNow != greenNew))
    {
    fade(redNow,redNew)
    fade(blueNow,blueNew)
    fade(greenNow,greenNew)
    analogWrite(blue, blueNow);
    analogWrite(red, redNow);
    analogWrite(green, greenNow);

    flickertime = random(20);
    digitalWrite(flickerLED,HIGH);
    delay(flickertime);
    digitalWrite(flickerLED,LOW);
    delay(20-flickertime);
  2. DanBKing

    DanBKing Dan the Man

    Joined:
    Feb 29, 2012
    Messages:
    1,659
    Likes Received:
    1,072
    Hahaha.... This is 'turning me on' just watching this baby come together!!!!! sign1

    :thumb::thumb::thumb::thumb::thumb:
  3. Zathros

    Zathros Guest

    If you wrote; digitalWrite(13, HIGH); wouldn't it stay in that model till either shut off (powering down) or a : digitalWrite(13, LOW); to turn it off command?
  4. imcold

    imcold Member

    Joined:
    Feb 3, 2008
    Messages:
    122
    Likes Received:
    1
    Is that the whole code? There are no no ending curly brackets  for the loop() function nor the while() block. And the #define looks unfinished. If I had to guess...

    PHP:
    int red 11//this sets the red led pin
    int green 10//this sets the green led pin
    int blue 9//this sets the blue led pin
    int flickerLED 8// flicker on pin 8

    int redNow;
    int blueNow;
    int greenNow;
    int redNew;
    int blueNew;
    int greenNew;
    int flickertime;

    void setup()
    //this sets the output pins
      
    pinMode(redOUTPUT);
      
    pinMode(greenOUTPUT);
      
    pinMode(blueOUTPUT);
      
    pinMode(flickerLED,OUTPUT);
      
    redNow random(255);
      
    blueNow random(255);
      
    greenNow random(255);
      
    redNew redNow;
      
    blueNew blueNow;
      
    greenNew greenNow;
    }

    #define fade(x,y) if (x>y) x--; else if (x<y) x++;

    void loop()
    {
      
    analogWrite(blueblueNow);
      
    analogWrite(redredNow);
      
    analogWrite(greengreenNow);
      
    redNew random(255);
      
    blueNew random(255);
      
    greenNew random(255);
      
    // fade to new colors
      
    while ((redNow != redNew) ||
        (
    blueNow != blueNew) ||
        (
    greenNow != greenNew))
      {
        
    fade(redNow,redNew)
        
    fade(blueNow,blueNew)
        
    fade(greenNow,greenNew)
        
    analogWrite(blueblueNow);
        
    analogWrite(redredNow);
        
    analogWrite(greengreenNow);

        
    flickertime random(20);
        
    digitalWrite(flickerLED,HIGH);
        
    delay(flickertime);
        
    digitalWrite(flickerLED,LOW);
        
    delay(20-flickertime);
      }
    }
  5. Zathros

    Zathros Guest

    You might want to take a working program, and modify it to get the results you wish. There's a face LED program on the Arduino site I'd start with. I am going to buy one of these. I was waiting for Raspberry PI for the Video functions, USB ports, keyboard, mouse etc. You can also write the code while it's running. Of course, here,in the "Land of the Free", it's not to be found! I wish someone would start a thread on this. I would, but i don't know what I am talking about. Maybe I'll just buy the Arduino.
  6. dnalor

    dnalor Active Member

    Joined:
    Oct 28, 2011
    Messages:
    928
    Likes Received:
    183
    the problem is that the sketch was a working programm that i found of the internet :)
    well...some of the lines has been lost i think..hum...with the copy paste..
    i looked it over and found the error...
    the first edition was ok and complete..
    somebody put the flicker in the sketch..and lost some code-lines
    And that i copied the first time ....but it is corrected and updated with ahum my own steady light line..it's not much but that is my drop of codec :-D

    Now the soldering of the lights in the ship...


    That raspberry sounds really great...a great price..
    only that about the whole world wants one....and they can't produce that fast. (says wiki)

    Maybe in a year they will be cloned and to be found everywhere..

    final draft of the sketch file

    int red = 12; //this is for the cockpit-r2 color red
    int green = 11; //this is for the cockpit color green
    int blue = 8; //this is for the cockpit-r2 color blue
    int flickerLED = 10; // this for burning engines.
    int steady = 13; // this the red main engine fire.

    int redNow;
    int blueNow;
    int greenNow;
    int redNew;
    int blueNew;
    int greenNew;
    int flickertime;

    void setup()
    { //this sets the output pins
    pinMode(red, OUTPUT);
    pinMode(green, OUTPUT);
    pinMode(blue, OUTPUT);
    pinMode(flickerLED,OUTPUT);
    pinMode(steady,OUTPUT);

    redNow = random(255);
    blueNow = random(255);
    greenNow = random(255);
    redNew = redNow;
    blueNew = blueNow;
    greenNew = greenNow;
    }
    #define fade(x,y) if (x>y) x--; else if (x<y) x++;
    void loop()
    {
    analogWrite(blue, blueNow);
    analogWrite(red, redNow);
    analogWrite(green, greenNow);
    redNew = random(255);
    blueNew = random(255);
    greenNew = random(255);
    // fade to new colors
    while ((redNow != redNew) ||
    (blueNow != blueNew) ||
    (greenNow != greenNew))
    {
    fade(redNow,redNew)
    fade(blueNow,blueNew)
    fade(greenNow,greenNew)
    analogWrite(blue, blueNow);
    analogWrite(red, redNow);
    analogWrite(green, greenNow);
    delay(20);
    flickertime = random(20);
    digitalWrite(flickerLED,HIGH);
    delay(flickertime);
    digitalWrite(flickerLED,LOW);
    delay(20-flickertime);


    //steady light for the engine
    digitalWrite(steady, HIGH);

    }
    }
  7. vbsargent

    vbsargent Member

    Joined:
    Apr 17, 2008
    Messages:
    188
    Likes Received:
    3
    Wow, this is VERY interesting. And tempting. I'm thinking of some lights for UHU's U-96 when I make it. It will have torpedoes, and I'm thinking about an interior to the conning tower, and possibly open hatches down to the control room with red night lights. And I'll enlarge to 1/72nd scale. This could give me the flicking red and green running lights as well as the steady red . . . . hmmmm . . . maybe both white AND red lights for the interior. They change for battle stations . . .
  8. Zathros

    Zathros Guest

    You are right about Raspberry PII, it is under manufactured. I have to read more on the Arduino, combined with the remains of my electronics lab will give me a way of connecting my son with all this stuff he is going to inherit, this can branch into making some kind of automaton in my machine shop, and pull him off the video games, but his own desire, not by a command.

    Does the Arduino have any graphics capabilities? I am going to have to research this more. I like the idea of having breadboxes for different purposes, and moving the unit from circuit to circuit, and then finalizing a component, and making a circuit board.
  9. Zathros

    Zathros Guest

    This thread is also becoming a sticky. It has much information. Relevant, and pertinent! :)
  10. dnalor

    dnalor Active Member

    Joined:
    Oct 28, 2011
    Messages:
    928
    Likes Received:
    183
  11. JackFrost

    JackFrost Member

    Joined:
    Jun 8, 2007
    Messages:
    78
    Likes Received:
    0
    dude, that is beautiful.another thing to watch and learn :)
  12. Marko_Dakkar

    Marko_Dakkar New Member

    Joined:
    Jun 3, 2012
    Messages:
    1
    Likes Received:
    0
    Awesome work! Do we ever get to see the final model?
  13. dnalor

    dnalor Active Member

    Joined:
    Oct 28, 2011
    Messages:
    928
    Likes Received:
    183
    off course...

    today i'm going to try to solder the first engine..
    i ordered some more leds..
    Also i'm working on some little parts

    step by step...the x wing grows..
  14. DanBKing

    DanBKing Dan the Man

    Joined:
    Feb 29, 2012
    Messages:
    1,659
    Likes Received:
    1,072
    The journey of a million kilometers begins with only one step .... :thumb:
  15. dnalor

    dnalor Active Member

    Joined:
    Oct 28, 2011
    Messages:
    928
    Likes Received:
    183
    Ok..

    After some solding..hum is that english?..:)
    i connected the leds with the cables...
    i learned that i don't like that :)

    But it looks nice..

    for the other 3 engines i want to try to place the red in the middel.
    but there is not much space.

    http://www.youtube.com/watch?v=RpciI_cedM0

    Attached Files:

  16. Rhaven Blaack

    Rhaven Blaack ADMINISTRATOR Administrator

    Joined:
    Jun 12, 2009
    Messages:
    7,416
    Likes Received:
    2,253
    It looks like this project is coming along very nicely.
    The engine with the lights looks very good.
    Thank you for sharing the video.
  17. imcold

    imcold Member

    Joined:
    Feb 3, 2008
    Messages:
    122
    Likes Received:
    1
    That Arduino board is so tiny compared to the engine that it looks quite funny :D
  18. dnalor

    dnalor Active Member

    Joined:
    Oct 28, 2011
    Messages:
    928
    Likes Received:
    183
    And still it's just to big to slide in the xwing..
    Now i need to make the hole larger :-(
  19. dnalor

    dnalor Active Member

    Joined:
    Oct 28, 2011
    Messages:
    928
    Likes Received:
    183
    Engine two and three are burning...(only the leds) ;-)
    I have some light leaking on the seams someting i think i can fix with some paper.

    Also i'm starting with the guns..
    But don't find a suitable support-rod...
    The best i find is a large Mc donalds drinking straw..
    But that only fits the tip..
    The other parts i have to make them some thinker with paper.

    Attached Files:

  20. dnalor

    dnalor Active Member

    Joined:
    Oct 28, 2011
    Messages:
    928
    Likes Received:
    183
    Ok..
    Engine 4 has light..
    Just making the diffuser and tonight installing the backside to the engine.

    Attached Files: