Iron Man War Machine Mark III LED's

Was wondering if someone would be able to help with a Arduino Sketch for my War machine. I am new at programming and have watched Davids videos but still struggling a bit. I'm currently building a replica of the War Machine Mark III (Attached photo) and want to be able to have my Leds on the unibeam gradually brighten at start up. I am using Tinycircuts for the board and a neopixel ring to start with.  I started a sketch to get the color and flickering effect but not sure how to make it gradually brighten at start up? (Sketch below) Any assistance would be greatly appreciated.

 

#include <Adafruit_NeoPixel.h>
 

#define PIN 6

 
Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);


void setup() {
  // put your setup code here, to run once:
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
   
for ( int led=0; led<12; led++){
strip.setPixelColor(led, 180,20,2); 

   strip.show();
   delay (5);

}

for ( int led=0; led<12; led++){
strip.setPixelColor(led, 200,25,0); 

   strip.show();
   delay (5);
}
}

Comments

  • How fast do you want the intensity to take to ramp up?
    You can use the NeoPixel "strip.setBrightness();" command to adjust the overall brightness...
  • Trying to do in about 4 Seconds. I did see that command, but wasn't sure how to incorporate it into the sketch so it doesn't repeat in a loop over and over. Just wanted it to do it once when I press the button and then remain at full brightness. 
  • edited March 2017
    Played with the "strip.setBrightness()" command a bit..
    Got this to work..
    It ramps up in 1 second steps over the first 8 seconds..
    My example uses red/blue colors just to make the led activity more noticeable..
    Kinda clunky but it works..



    #include <Adafruit_NeoPixel.h>

    #define PIN 6
    #define wait 10

    int brightness = 0;
    unsigned long previousMillis = 0;
    unsigned long currentMillis = 0;

    Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);

    void setup() {

      strip.begin();
      strip.show(); // Initialize all pixels to 'off'

    }



    void loop() {

      currentMillis = millis();

      if (currentMillis - previousMillis >= 1000) {
        brightness = 2;
      }

      if (currentMillis - previousMillis >= 2000) {
        brightness = 4;
      }

      if (currentMillis - previousMillis >= 3000) {
        brightness = 8;
      }

      if (currentMillis - previousMillis >= 4000) {
        brightness = 16;
      }

      if (currentMillis - previousMillis >= 5000) {
        brightness = 32;
      }

      if (currentMillis - previousMillis >= 6000) {
        brightness = 64;
      }

      if (currentMillis - previousMillis >= 7000) {
        brightness = 128;
      }

      if (currentMillis - previousMillis >= 8000) {
        brightness = 255;
      }


      for ( int led = 0; led < 12; led++) {
        strip.setPixelColor(led, 255, 0, 0);
        strip.setBrightness(brightness);
        strip.show();
        delay (wait);

      }

      for ( int led = 0; led < 12; led++) {
        strip.setPixelColor(led, 0, 0, 255);
        strip.setBrightness(brightness);
        strip.show();
        delay (wait);
      }

    }


  • Thank you Bob,

    Really looking forward to trying this out tonight. At least it gets me started in the right direction, I am a total noob when it comes to programing but I am starting to learn more and more every day thanks to this awesome school and community.  :)

  • No worries....
    I probably should have put comments in the code so don't hesitate to ask questions...
    It's by no means any sort of elegant solution...

  • I made a small mistake in the code above so use this one instead.
    I added some comments.


    #include <Adafruit_NeoPixel.h>

    #define PIN 6                       // data connection to NeoPixel
    #define wait 5                     // delay for led effects

    int brightness = 0;                 // led brightness value
    unsigned long startMillis = 0;      // initial millis value
    unsigned long currentMillis = 0;    // current millis value

    Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);   // setup NeoPixel

    void setup() {

      strip.begin();            // start NeoPixel
      strip.show();             // Initialize all pixels to 'off'
      startMillis = millis();   // get initial millis value

    }


    void loop() {

      currentMillis = millis();  // get current millis value

      // if current millis value more than 0.5 second than initial then make brightness 1
      if (currentMillis - startMillis >= 500) {
        brightness = 1;
      }

      // if current millis value more than 1.0 second than initial then make brightness 2
      if (currentMillis - startMillis >= 1000) {
        brightness = 2; 
      }
      
      // if current millis value more than 1.5 second than initial then make brightness 4
      if (currentMillis - startMillis >= 1500) {
        brightness = 4;   
      }
      
      // if current millis value more than 2.0 second than initial then make brightness 8
      if (currentMillis - startMillis >= 2000) {
        brightness = 8; 
      }
      
      // if current millis value more than 2.5 second than initial then make brightness 16
      if (currentMillis - startMillis >= 2500) {
        brightness = 16;
      }
      
      // if current millis value more than 3.0 second than initial then make brightness 32
      if (currentMillis - startMillis >= 3000) {
        brightness = 32; 
      }
      
      // if current millis value more than 3.5 second than initial then make brightness 64
      if (currentMillis - startMillis >= 3500) {
        brightness = 64;
      }
      
      // if current millis value more than 4.0 second than initial then make brightness 128
      if (currentMillis - startMillis >= 4000) {
        brightness = 128;
      }

      // if current millis value more than 4.5 second than initial then make brightness 128
      if (currentMillis - startMillis >= 4500) {
        brightness = 255;
      }
      
      // do led effect #1
      for ( int led = 0; led < 12; led++) {
        strip.setPixelColor(led, 255, 0, 0);
        strip.setBrightness(brightness);
        strip.show();
        delay (wait);
      }

      // do led effect #2
      for ( int led = 0; led < 12; led++) {
        strip.setPixelColor(led, 0, 0, 255);
        strip.setBrightness(brightness);
        strip.show();
        delay (wait);
      }

    }

Sign In or Register to comment.