Pages: [1]   Go Down
Author Topic: IRON MAN FACE PLATE AND JAW  (Read 2113 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  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
}
}
« Last Edit: June 06, 2013, 11:40:49 am by Dentingleopard » Logged

Pages: [1]   Go Up
Jump to: