Iron man motorised faceplate electronics tutorial!!!

good idea, I'll think I might rip out my posts/code/diagrams and make a separate post to keep it clean and direct so there is no confusion on the many approaches.
 
Good Afternoon all who are still following
i have been following the thread for a while now, i have asked a few questions and had amazing responses, though i am pretty much as noobie as they come to this never attempting anything like it of any sort, thanks to this thread i have now completed my first foam build iron man suit, its not perfect i know what and i have already start my MKII which thanks this amazing community is already so much better, i don't really have anything to offer as everything i learnt was from here so i would like to thank everyone as i'm sure somewhere along my build lots of you help me out a lot. if you fancy having a look at my first build i'll post my youtube clip below. So thank you again and keep it the amazing work!

https://www.youtube.com/watch?v=C68t-dRmtxo
 
Good Afternoon all who are still following
i have been following the thread for a while now, i have asked a few questions and had amazing responses, though i am pretty much as noobie as they come to this never attempting anything like it of any sort, thanks to this thread i have now completed my first foam build iron man suit, its not perfect i know what and i have already start my MKII which thanks this amazing community is already so much better, i don't really have anything to offer as everything i learnt was from here so i would like to thank everyone as i'm sure somewhere along my build lots of you help me out a lot. if you fancy having a look at my first build i'll post my youtube clip below. So thank you again and keep it the amazing work!

https://www.youtube.com/watch?v=C68t-dRmtxo


Beautiful build Danny. You've inspired me to get my current build finished. Thank you for inspiring me to get motivated.
 
So I copied your code and tried it and the lights work but not I cant get the servos to work. When trying to verify the code it says that it is not correct. It fails in this spot

myservo.attach(9);
myservo1.attach(10);
pinMode(switchPin, INPUT);
pinMode(ledPin, OUTPUT);
buttonState = digitalRead(switchPin);
myservo.slowmove(0, 30); // move to 0 degrees, use a speed of 30, wait until move is complete
myservo1.slowmove(120, 30);
pinMode(ledPin2, OUTPUT);
}
 
Not tried it myself yet but having read through it all and seen common things there's a chance your servo doesn't want to move to 0 degrees? Not all of them have a full range of motion so it could be something related to that. Maybe try changing that to 10 or 20 degrees

Can't comment on the code itself but it's a starting point hopefully.
 
Its failing before the code is even being updated.. so its not a servo range thing.

(it would work.. but grind at those positions if that were the case most likely)

iron gilly

post the error message too.. what line?

have you included the correct library?

I believe he is using a custom servo library that is not included in the IDE.. you need to add it if not done already.

also, please post any code between code tags.. makes it easier for everyone to read.
 
Last edited by a moderator:
so I figured it out. Not sure why that one code was not working but I got this on to wok for me.

Servo myservo; // create servo object to control a servo
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

// led control pins (need to be PWM enabled pins for fading)
const int leftEye = 5; // the number of the left eye/pcb LEDs
const int rightEye = 5; // the number of the right eye/pcb LEDs
unsigned long fadeDelay = .5; //speed of the eye 'fade'
unsigned long callDelay = 700; //length to wait to start eye flicker after face plate comes down
unsigned long blinkSpeed = 100; //delay between init blink on/off
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
#define S_SERVOWAIT 10

//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(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
//one blink
analogWrite(leftEye, 155);
analogWrite(rightEye, 155);
delay(blinkSpeed);
analogWrite(leftEye, 0);
analogWrite(rightEye, 0);
delay(10);
//two blinks
/*
analogWrite(leftEye, 155);
analogWrite(rightEye, 155);
delay(blinkSpeed);
analogWrite(leftEye, 0);
analogWrite(rightEye, 0);
delay(10);
*/
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 + fadeDelay)){
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 + fadeDelay)){
if(currentPWM > 0){ //change 0 to higher number to init face 'up' function sooner.
currentPWM -= 5;
state = S_LEDOFF;
}
else{
Serial.println("@ 0 done........");
state = S_SERVOUP; //leds off..raise faceplate
}
}
break;
case S_SERVOUP:
Serial.println("servo up.........");
myservo.write(0);
state = S_IDLE;
break;
case S_SERVODOWN:
lastTime = millis(); // Remember the current time
Serial.println("servo down.........");
myservo.write(179);
state = S_SERVOWAIT;
break;
case S_SERVOWAIT:
// If enough time has passed, call the eye flicker routine
if(millis() > (lastTime + callDelay)){
Serial.println("start eye flicker routine");
state = S_BLINKON;
}
else{
Serial.println("waiting........");
}
break;
default:
state = S_IDLE;
break;
}
}
 
*I would suggest you read the thread again it seems as if you are just randomly putting stuff together?

* please use code tags when posting code in a thread.



anyways...

the code you posted happens to be mine (at least it looks that way to me).. make sure you are using the correct wiring diagram....

do you have an video of things 'in-action'?
 
@xl97 I bow to the voice of experience. Saw the first line of his question and thought that meant he'd got the code running. I might have more of a clue with this once my bits turn up and I get going myself.

Just want to chip in just now and say thanks so much to you (xI97), @memebr and @7sinzz for all the info you've gathered and shared here. It's a massive help. Really interesting read as well. Cheers.
 
Hey thank you so much for this, i just have one problem, when i push the button, nothing happens. if i remove the button, the helmet goes up and when i put back the button on the breadboard the helmet goes back down. any thoughts? is it a faulty button?
 
Is the switch (button) installed wrong? post a pic? what switch?

more info needed to provide help.
 
11223697_861989297225202_5866499304212325657_n.jpg11238736_861989340558531_6529430574995982425_n.jpg when i push the button nothing happens, when i take out the button, it moves 180 degrees and when i put the button back, it moves back to 0. i must be doing something wrong, also i took out the led section cause it was not needed. even when i had the led in the breadboard, the button still wouldn
t work, help needed!
 
View attachment 504538View attachment 504539 when i push the button nothing happens, when i take out the button, it moves 180 degrees and when i put the button back, it moves back to 0. i must be doing something wrong, also i took out the led section cause it was not needed. even when i had the led in the breadboard, the button still wouldn
t work, help needed!


post the code you do have as of now and we'll take a look
 
* (probably wrong wiring diagram with wrong code)

* (I hope your not powering that servo from your Arduino?) (and it isnt under any load, of any kind)

* (in the end I dont think you'll be able to power your project (Arduino/Servo from your/any USB)
 
I presume the code is from the original post. I have the exact same issue. I thought I could use the USB power without running the LED as a test (servos under no load), but opted to run a battery pack to the servos and have the arduino powered by the usb by itself. I got about 38 pages into this thread, still have a lot more reading and note taking to do! Getting the same problem with the button not working. For me, if I pull either of the power cables that link the button, it works as if i pressed the button. I need to finish wiring in separate power and regulating properly before I am going to post up the pics to see if things are being under-powered and malfunction because it isnt getting enough juice.
 
I just wanted to come back to this thread after about 3 months of building to say thank you for the inspiration for making a motorized Iron Man Mk 2 Helmet, Im nearing completion and it could not have been more fun!

All of my electronics worked out perfectly and the movement of the faceplate is nice and smooth. Also the eye blink before they turn on looks fantastic.

Thank you to all the people who post in this thread and for the awesome code provided. Check out my build for yet more videos of how the servo mechanism in this tutorial works.

I hope I can answer some questions aswell. Please keep up the good work guys and maybe I will see you in my next build?
 
I presume the code is from the original post. I have the exact same issue. I thought I could use the USB power without running the LED as a test (servos under no load), but opted to run a battery pack to the servos and have the arduino powered by the usb by itself. I got about 38 pages into this thread, still have a lot more reading and note taking to do! Getting the same problem with the button not working. For me, if I pull either of the power cables that link the button, it works as if i pressed the button. I need to finish wiring in separate power and regulating properly before I am going to post up the pics to see if things are being under-powered and malfunction because it isnt getting enough juice.

well for fear of insulting/being rude..

I'd suggest NOT using the code in the first post.. initially there was no real direction, and it was looking for help as I recall... and has been built up form other responses/posts.. so in the OP's defense.. I'm sure whats been done.. what wiring diagram, and what code..etc

I would (myself) choose to follow either memebrs or my code, and then following the matching wiring diagram.

There are slight differences in the code that match the slight differences in the wiring.

ie: one code is checking for a button to be hi, while the other is checking for the button to be lo.. (and the wiring to match)


I would also ensure you giving your servos what they need.. (most need +6v?).. so powering form USB only gives them +5v... not to mention there is not enough current available to properly drive a servo (much less two under load)
 
I gotcha, I've actually been using your diagram as a reference beyond the first post. To clarify, I was power the arduino with the USB. I was running a pair of servos with a 4 AA batteries pack under no load for testing. My servos are listed as 5v to 12v capable. I'll more than likely fade back into obscurity and refrain from posting until I re-read a lot of the critical posts and triple check all my components before asking any questions to avoid asking the same questions that have already been answered. I'm sure explanations of everything are in here, I just have to find them! :lol I've had to reel it back from overzealous mashing together of wiring and code and parts to slow and meticulous. Electronics are so finicky! That being said, thanks again for all your input throughout this thread. Having multiple build options is awesome and the steps you guys/gals have gone through to compile this knowledge is amazing.
 
I gotcha, I've actually been using your diagram as a reference beyond the first post. To clarify, I was power the arduino with the USB. I was running a pair of servos with a 4 AA batteries pack under no load for testing. My servos are listed as 5v to 12v capable. I'll more than likely fade back into obscurity and refrain from posting until I re-read a lot of the critical posts and triple check all my components before asking any questions to avoid asking the same questions that have already been answered. I'm sure explanations of everything are in here, I just have to find them! :lol I've had to reel it back from overzealous mashing together of wiring and code and parts to slow and meticulous. Electronics are so finicky! That being said, thanks again for all your input throughout this thread. Having multiple build options is awesome and the steps you guys/gals have gone through to compile this knowledge is amazing.


depending on the voltage you do use with your servos, will depend greatly on how fast and how much of a load you can put on the servos. Also another thing to keep in mind is that if your servos are rated for 5v's each, and your running a 4xAA's to power them, your servos aren't getting the recommended voltage. I would try going with maybe 6 AA's to power both of them.
 
ubcs86

This might help:

http://www.therpf.com/showthread.php?t=243385


cleaned up tutorial thread....


(as mentioned I would stick with either mine or memebr's posts)


each code goes with the specific wiring diagram, and can not be inter-changed. :)

devildog12

Arent AA's 1.5v each? (meaning its a total of +6v coming from the pack?)


either way devidog12 is on the right track here.. ENSURE all components are getting the correct REGULATED voltage. :)
 
Last edited by a moderator:
Back
Top