Iron man motorised faceplate electronics tutorial!!!

The flicker effect I'm suggesting is to mimic powering up. Flicker twice then solid light.

Dirtybrit, The eye location on the breadboard is described in first post. It's represented by the green LED in my photos. Without looking I'm sure it's steps 3,4,5,17.

do you want the light blink 2 times then on.? or blink 2 times then fading ON..?
 
Try blink twice then fade on

try this sir. its working just replace the LED ON program of the servo.

digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(100);
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(100);


// fading
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
delay(30);

i hope it will help you :) just adjust the delay on fading and the fadevalue if you want it fast :love
 
I just wanted to take a moment to say thanx to the folks who have taken the time to contribute to this thread. For me, i who have no experience in electronics what so ever, have been trying to figure out how am i going to learn this strange langauge of electronics. You folks have paved the way, actually laid a solid foundation for guys like me to pickup and understand something that has until now, been alien to me. Thank-you all... GM
 
Am i understanding correctly that i can hook multiple leds to the board using the 2 jumper points listed in the original steps? Do these have have a transistor included as someone else posted... any chance of an dummies guide to this or a diagram?sorry to sound like an idiot... just dont wanna do anything that will damage the arduino!
 
you might be able to hook up '2' per pin.. and always use the correct resistor calculated for this.

but each Arduino pin can only give up to max 40mA I believe.. ..

if you use a transistor.. you can group more together.. and toggle the group together.. however you would only be using the Arduino to 'toggle' to logic gate.. not really be powering them from the Arduino as you would hook the power source to the transistor


also.. how many leds do you think each 'eye' will need.. and what kind? (need a datasheet for the leds you want to use.. so we can get a vF.....etc for it)
 
Guys quick update. Guitarkizta has supplied me with a rewritten foundation code to include eye flicker and fade on to mimic powering up. I've tweaked it so it will work with my physical set up and added the second servo to mirror the first. Needs a few more tweaks before i can publish it. Video and code will be available later. Thank you to guitarkizta for this.

I would suggest 3 LEDs per eye. At breadboard stage you don't need 8 though. This is just to test the code until your ready to move on. May I suggest stealths method for installing the eyes. Link to be provided later.
 
Guys quick update. Guitarkizta has supplied me with a rewritten foundation code to include eye flicker and fade on to mimic powering up. I've tweaked it so it will work with my physical set up and added the second servo to mirror the first. Needs a few more tweaks before i can publish it. Video and code will be available later. Thank you to guitarkizta for this.

I would suggest 3 LEDs per eye. At breadboard stage you don't need 8 though. This is just to test the code until your ready to move on. May I suggest stealths method for installing the eyes. Link to be provided later.

sir you can use 1 LED per eye. i just used 1 LED but i include transistor for external power 6v.
check my video :)
Ironman motorized helmet w/ automatic eye on/off - YouTube
i don't use the flicker and fading because i used all the PWM output for the other components :D
 
If you are only using 1 led.. why the need of a transistor? what type of led is it?

you must have some good diffusion behind the eye then? looks good for only 1 led..



anyways.. I too have been playing with some code..etc

(anybody got a cool whirrr or bzzz sound like the gears for the helmet when it opens/closes?.. I wanna try to incorporate those into the project as well) :)


anyways.. a few 'community' questions..

1.) If people are NOT using any type of limit switches.. how do we know if the helmet is opened or closed?

ie: we power the helmet/Arduino up.. (and the helmet is closed).. the eyes blink, and fade in.. ok..

but what if we powered it up with the helmet open? it would be backwards?..

just a question.. if there was a 'switch' of some kind that was open or closed based on the status of the faceplate.. we wouldnt have to worry about that type of scenario anymore. :)
 
Last edited:
If you are only using 1 led.. why the need of a transistor? what type of led is it?

you must have some good diffusion behind the eye then? looks good for only 1 led..



anyways.. I too have been playing with some code..etc

(anybody got a cool whirrr or bzzz sound like the gears for the helmet when it opens/closes?.. I wanna try to incorporate those into the project as well) :)


anyways.. a few 'community' questions..

1.) If people are NOT using any type of limit switches.. how do we know if the helmet is opened or closed?

ie: we power the helmet/Arduino up.. (and the helmet is closed).. the eyes blink, and fade in.. ok..

but what if we powered it up with the helmet open? it would be backwards?..

just a question.. if there was a 'switch' of some kind that was open or closed based on the status of the faceplate.. we wouldnt have to worry about that type of scenario anymore. :)

i used transistor for external power because i have to power more than 10 LED and 2 1 watt LED.. i used super bright LED white per eye and put some aluminum foil from coffee pack :lol

for the question for what if the helmet is open when you power on the arduino.. just declare the servo position when the arduino power on.. you can declare in at the void setup();

example

void setup();{
servo.write(180); // the close position of the face flate

}
you can also declare other components like the LEDs if you want the LED on when you power the arduino just put on the void setup(); void setup is for the initial execution of the arduino when it is power on if im not mistaken:lol

i hope it will help you sir :)
 
Just testing now...

With the current code i am using:
Assuming you are referring to a master power switch. If you turn off the power with the faceplate open, when you turn the power back on, the faceplate will close automatically and eyes will remain off.
1) First button press: 1 second delay then flickers then fades eyes on, no movement.
2) Second button press: Turns off eyes and opens faceplate.
3) Third button press: Closes faceplate, 1 second delay, eyes flicker then fade on.

Reference this video:
Iron man faceplate and eye lights with flicker and fade - YouTube

Code for eye flicker and fade will be in the first post later.
 
yeah... I was over thinking it a bit! LOL. :(

I forgot this will all be button activated.. so really no need to 'know'..

here is my quick sketch for the blink/fade in of the eyes..

I only use delay() in the first blink sequence..

*have not added in your servo code yet.. but should be VERY easy.. just make another 'state'



Code:
// IronMan Helmet: eye blink sequence_v1.0
// created by: xl97


// led control pins (need to be PWM enabled pins for fading)
const int leftEye =  6;  // the number of the left eye/pcb LEDs
const int rightEye =  3;  // the number of the right eye/pcb LEDs

/* we always wait a bit between updates of the display */
unsigned long delaytime = 1;
unsigned long fadespeed = 500;
unsigned long blinkspeed = 100;
unsigned long currentPWM = 0;

#define S_IDLE 1
#define S_LEDON 2
#define S_WAITON 3
#define S_LEDOFF 4
#define S_WAITOFF 5
#define S_INITON 6
#define S_INITWAIT 7
#define S_BLINKON 8


//FSM init vars
static int state = S_IDLE; // initial state is 1, the "idle" state.
static unsigned long lastTime;  // To store the "current" time in for delays.


void setup() {
  // Set up serial port
  Serial.begin(9600);  
  Serial.print("INTIT STATE: ");
  Serial.println(state);

  //start it off
  state = S_BLINKON; 
}





void loop() { 
  switch(state)
  {
  case S_IDLE:
    // We don't need to do anything here, waiting for a forced state change...like button press.
    break;

  case S_BLINKON:
    //do blink routine here
    analogWrite(leftEye, 155);
    analogWrite(rightEye, 155);
    delay(blinkspeed);
    analogWrite(leftEye, 0);
    analogWrite(rightEye, 0);
    delay(blinkspeed);
    analogWrite(leftEye, 155);
    analogWrite(rightEye, 155);
    delay(blinkspeed);
    analogWrite(leftEye, 0);
    analogWrite(rightEye, 0);
    delay(10);
    currentPWM = 0;
    
    state = S_LEDON;    
    break;

  case S_LEDON:
    Serial.println("increase........");
    analogWrite(leftEye, currentPWM);
    analogWrite(rightEye, currentPWM);
    lastTime = millis();  // Remember the current time
    state = S_WAITON;  // Move to the next state
    break;

  case S_WAITON:
    // If one second has passed, then move on to the next state.
    if(millis() > lastTime + delaytime)
    {
      if(currentPWM < 255){
        currentPWM++;
        state = S_LEDON;        
      }
      else{
        Serial.println("@255 done........");
        state = S_IDLE;
        //state = S_LEDOFF; //no auto turn off.. set to idle state
      }
    }
    break;

  case S_LEDOFF:
    Serial.println("........decrease"); 
    lastTime = millis();  // Remember the current time
    state = S_WAITOFF;
    break;

  case S_WAITOFF:
    // If one second has passed, then go back to state 2.
    if(millis() > lastTime + delaytime)
    {
      if(currentPWM > 0){
        currentPWM--;
        state = S_LEDOFF;        
      }
      else{
        state = S_LEDON;
      }
    }
    break;

  default:
    state = S_IDLE;
    break;
  } 
}
 
Last edited:
yeah... I was over thinking it a bit! LOL. :(

I forgot this will all be button activated.. so really no need to 'know'..

here is my quick sketch for the blink/fade in of the eyes..

I only use delay() in the first blink sequence..

*have not added in your servo code yet.. but should be VERY easy.. just make another 'state'



Code:
// IronMan Helmet: eye blink sequence_v1.0
// created by: xl97


// led control pins (need to be PWM enabled pins for fading)
const int leftEye =  6;  // the number of the left eye/pcb LEDs
const int rightEye =  3;  // the number of the right eye/pcb LEDs

/* we always wait a bit between updates of the display */
unsigned long delaytime = 1;
unsigned long fadespeed = 500;
unsigned long blinkspeed = 100;
unsigned long currentPWM = 0;

#define S_IDLE 1
#define S_LEDON 2
#define S_WAITON 3
#define S_LEDOFF 4
#define S_WAITOFF 5
#define S_INITON 6
#define S_INITWAIT 7
#define S_BLINKON 8


//FSM init vars
static int state = S_IDLE; // initial state is 1, the "idle" state.
static unsigned long lastTime;  // To store the "current" time in for delays.


void setup() {
  // Set up serial port
  Serial.begin(9600);  
  Serial.print("INTIT STATE: ");
  Serial.println(state);

  //start it off
  state = S_BLINKON; 
}





void loop() { 
  switch(state)
  {
  case S_IDLE:
    // We don't need to do anything here, waiting for a forced state change...like button press.
    break;

  case S_BLINKON:
    //do blink routine here
    analogWrite(leftEye, 155);
    analogWrite(rightEye, 155);
    delay(blinkspeed);
    analogWrite(leftEye, 0);
    analogWrite(rightEye, 0);
    delay(blinkspeed);
    analogWrite(leftEye, 155);
    analogWrite(rightEye, 155);
    delay(blinkspeed);
    analogWrite(leftEye, 0);
    analogWrite(rightEye, 0);
    delay(10);
    currentPWM = 0;
    
    state = S_LEDON;    
    break;

  case S_LEDON:
    Serial.println("increase........");
    analogWrite(leftEye, currentPWM);
    analogWrite(rightEye, currentPWM);
    lastTime = millis();  // Remember the current time
    state = S_WAITON;  // Move to the next state
    break;

  case S_WAITON:
    // If one second has passed, then move on to the next state.
    if(millis() > lastTime + delaytime)
    {
      if(currentPWM < 255){
        currentPWM++;
        state = S_LEDON;        
      }
      else{
        Serial.println("@255 done........");
        state = S_IDLE;
        //state = S_LEDOFF; //no auto turn off.. set to idle state
      }
    }
    break;

  case S_LEDOFF:
    Serial.println("........decrease"); 
    lastTime = millis();  // Remember the current time
    state = S_WAITOFF;
    break;

  case S_WAITOFF:
    // If one second has passed, then go back to state 2.
    if(millis() > lastTime + delaytime)
    {
      if(currentPWM > 0){
        currentPWM--;
        state = S_LEDOFF;        
      }
      else{
        state = S_LEDON;
      }
    }
    break;

  default:
    state = S_IDLE;
    break;
  } 
}

that's nice :) how many LED's do you used in your eyes..?
 
Just testing now...

With the current code i am using:
Assuming you are referring to a master power switch. If you turn off the power with the faceplate open, when you turn the power back on, the faceplate will close automatically and eyes will remain off.
1) First button press: 1 second delay then flickers then fades eyes on, no movement.
2) Second button press: Turns off eyes and opens faceplate.
3) Third button press: Closes faceplate, 1 second delay, eyes flicker then fade on.

Reference this video:
Iron man faceplate and eye lights with flicker and fade - YouTube

Code for eye flicker and fade will be in the first post later.

yeah! nice!
 
hi-

I just used one led per eye.. for the demo/test code.. but would make a PCB for 'several' leds if I were doing this myself..

(I dont even have an IM helmet.. but would like to find a nice, cheap one to play along and add electronics too!)


I'll add in some more stuff.. all vars are editable at top.. (to make speed etc easy to aler)
 
ok.. here is my latest stab at it:

*Summary:


1.) 1 x button (digital pin 2) controls both open and close operations
2.) when OPEN.. the servos will close and then trigger the led 'blink & fade in' routine
3.) when CLOSED... the leds will fade out then the servos will 'open'.

should be a very scalable and easy editable sketch so far:


Code:
// IronMan Helmet: eye blink sequence_v1.0
// created by: xl97
// [url=http://www.therpf.com]Movie Props, Costumes and Scale Models | the RPF[/url] thread: 
// [url]http://www.therpf.com/f24/iron-man-motorised-faceplate-electronics-tutorial-170853/index3.html#post2647126[/url]

//import servo lib
#include <Servo.h>

//servo object names
Servo myservo; // create servo object to control a servo
Servo myservo1;

const int buttonPin = 2; // the pin that the pushbutton is attached to
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
int pos = 0; // variable to store the servo positions
int pos1 = 180;

// led control pins (need to be PWM enabled pins for fading)
const int leftEye =  6;  // the number of the left eye/pcb LEDs
const int rightEye =  3;  // the number of the right eye/pcb LEDs

unsigned long delaytime = 1;
unsigned long blinkspeed = 100;
unsigned long currentPWM = 0;
boolean isOpen = true;

#define S_IDLE 1
#define S_LEDON 2
#define S_WAITON 3
#define S_LEDOFF 4
#define S_WAITOFF 5
#define S_INITON 6
#define S_INITWAIT 7
#define S_BLINKON 8
#define S_SERVOUP 9
#define S_SERVODOWN 0



//FSM init vars
static int state = S_IDLE; // initial state is 1, the "idle" state.
static unsigned long lastTime;  // To store the "current" time in for delays.


void setup() {
  // Set up serial port
  Serial.begin(9600);  
  //start it off
  //state = S_BLINKON; 
  Serial.print("INTIT STATE: ");
  Serial.println(state);

  myservo.attach(9); // attaches the servo on pin 9 to the servo object
  myservo1.attach(10); // attaches the servo on pin 10 to the servo object

  pinMode(buttonPin, INPUT); // initialize the button pin as a input
  digitalWrite(buttonPin, HIGH); //use interal pull up resistors
}

void loop() { 
  switch(state)
  {
  case S_IDLE:
    // We don't need to do anything here, waiting for a forced state change...like button press.
    //check mian button state
    buttonState = digitalRead(buttonPin);

    // compare buttonState to previous state  
    if (buttonState != lastButtonState) {
      //if button pressed/down
      if (buttonState == LOW){
        //ie: pressed   
        if(isOpen == true){
          Serial.print("CLOSING FACE PLATE: ");
          Serial.println(isOpen, DEC); 
          state = S_SERVODOWN;
        }
        else{
          Serial.print("OPENING FACE PLATE: ");
          Serial.println(isOpen, DEC); 
          //state = S_SERVOUP;
          state = S_LEDOFF;
        }
        isOpen = !isOpen;

      }
      else{
        //went from ON/HIGH to LOW/OFF..ie: released
        //Serial.print("RELEASE: ");
        //Serial.println(isOpen, DEC); 
      } 

    }
    // save the current state for next loop
    lastButtonState = buttonState;
    break;

  case S_BLINKON:
    Serial.println("init blink.........");   
    //do blink routine here
    analogWrite(leftEye, 155);
    analogWrite(rightEye, 155);
    delay(blinkspeed);
    analogWrite(leftEye, 0);
    analogWrite(rightEye, 0);
    delay(10);
    /*
    analogWrite(leftEye, 155);
    analogWrite(rightEye, 155);
    delay(blinkspeed);
    analogWrite(leftEye, 0);
    analogWrite(rightEye, 0);
    delay(10);
    */    
    currentPWM = 0;
    state = S_LEDON;    
    break;

  case S_LEDON:
    Serial.println("increase........");    
    lastTime = millis();  // Remember the current time
    analogWrite(leftEye, currentPWM);
    analogWrite(rightEye, currentPWM);
    state = S_WAITON;  // Move to the next state
    break;

  case S_WAITON:
    // If one second has passed, then move on to the next state.
    if(millis() > lastTime + delaytime)
    {
      if(currentPWM < 255){
        currentPWM += 5;
        state = S_LEDON;        
      }
      else{
        Serial.println("@ 255 done........");
        state = S_IDLE;
        //state = S_LEDOFF; //no auto turn off.. set to idle state
      }
    }
    break;

  case S_LEDOFF:
    Serial.println("........decrease");     
    lastTime = millis();  // Remember the current time
    analogWrite(leftEye, currentPWM);
    analogWrite(rightEye, currentPWM);
    state = S_WAITOFF;
    break;

  case S_WAITOFF:
    // If one second has passed, then move on to the next state.
    if(millis() > lastTime + delaytime)
    {
      if(currentPWM > 0){
        currentPWM -= 5;
        state = S_LEDOFF;        
      }
      else{
        Serial.println("@ 0 done........");
        state = S_SERVOUP; //leds off..raise faceplate
      }
    }
    break; 

  case S_SERVOUP:
    myservo.write(100);
    myservo1.write(100);
    //delay(20); //wait to trigger the led flicker.. will remove delay() use in next revision
    state = S_IDLE;
    Serial.println("servo up.........");   
    break;

  case S_SERVODOWN:
    myservo.write(0);
    myservo1.write(0);
    delay(20); //wait to trigger the led flicker.. will remove delay() use in next revision
    state = S_BLINKON;
    Serial.println("servo down.........");   
    break;

  default:
    state = S_IDLE;
    break;
  } 
}
 
This thread is more than 4 years old.

Your message may be considered spam for the following reasons:

  1. This thread hasn't been active in some time. A new post in this thread might not contribute constructively to this discussion after so long.
If you wish to reply despite these issues, check the box below before replying.
Be aware that malicious compliance may result in more severe penalties.
Back
Top