Go Down

Topic: IRON MAN FACE PLATE AND JAW (Read 2746 times) previous topic - next topic

Jun 06, 2013, 06:28 pm Last Edit: Jun 06, 2013, 06:40 pm by Dentingleopard Reason: 1
I AM TRYING MAKE A IRON MAN HELMET WHERE THE LIGHTS GO ON AND OFF FACE PLATES OPENS AND CLOSE AND AS WELL AS THE JAW LIKE THIS VIDEO HERE http://www.youtube.com/watch?v=8G0ozF1Gs_k  I ALREADY HAVE A CODE THAT  DOES ALL THAT EXCEPT  THE JAW MOVE BASICCALY ADDING 2 MORE SERVOS. CAN ANY BODY HELP ME ALSO WONDER IF ANYBODY CAN TELL ME HOW MUCH I WOULD NEED TO POWER ALL THIS(WHAT TYPE AND HOW MANY BATTERYS) HERE IS THE INSTRUCTIONS. THERE ARE 2 CODES IN THE LINK. I WILL BE USING AND THE CODE THAT will make the LED flicker then fade on, one second after the faceplate closes. Mimicking a powering up function AND ALSO WHAT WOULD I HAVE TO DO THIS BREAD BOARD IF ANYTHING TO ADD 2 MORE SERVOS THANK YOU IN ADVANCE


LINK http://www.therpf.com/f24/iron-man-motorised-faceplate-electronics-tutorial-170853/

CODE
#include <Servo.h>
//servo 1
Servo myservo;
Servo myservo1;
int val; // variable for reading the pin status
int val2; // variable for reading the delayed/debounced status
int buttonState;
int pos = 0;
int pos1 = 180;
int servostatus = 0;
int switchPin =2; // Switch connected to digital pin 2
int ledPin = 5;
int ledPin2 = 18;
void setup() // run once, when the sketch starts
{
//servo 1

myservo.attach(9);
myservo1.attach(10);
pinMode(switchPin, INPUT);
pinMode(ledPin, OUTPUT);
buttonState = digitalRead(switchPin);
myservo.write(0);
myservo1.write(175);
pinMode(ledPin2, OUTPUT);
}

void loop() // run over and over again

//servo 1
{
val = digitalRead(switchPin); // read input value and store it in val
delay(10); // 10 milliseconds is a good amount of time
val2 = digitalRead(switchPin); // read the input again to check for bounces
if (val == val2) { // make sure we got 2 consistant readings!
if (val != buttonState) { // the button state has changed!
if (val == LOW) { // check if the button is pressed
if (servostatus == 0) { // is the light off?
servostatus = 1; // turn light on!

myservo.write(0);
myservo1.write(180);
delay(1000);
digitalWrite(ledPin, HIGH);
delay(50);
digitalWrite(ledPin, LOW);
delay(00);
digitalWrite(ledPin, HIGH);
delay(50);
digitalWrite(ledPin, LOW);
delay(00);


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


}

} else {
servostatus = 0; // turn light off!


digitalWrite(ledPin, LOW);
delay(15);
digitalWrite(ledPin2, LOW);
myservo.write(180);
myservo1.write(0);






}
}
}
buttonState = val; // save the new state in our variable
}
}

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy