Iron man motorised faceplate electronics tutorial!!!

Don't want to see this ad? Sign up for anRPF Premium Membershiptoday. Support the community. Stop the ads.


laf770

New Member
super old thread, i know. SUPER NOOB here. i know nothing about code or arduinos. copied the code in this thread to my arduino and i am trying to motorize the faceplate on my helmet and the lights are coming on when the helmet is open, not closed. i have tried all kinds of ways to turn the servo to make it work,but the hinge system i have just wont work unless it is set up the way i have it. i just need to get the lights to come on the opposite of when they are. tried editing code, but again i know nothing. was able to figure out how to adjust travel on the servo, but thats all i could do on my own. if anybody reads this, and can please point me in the right direction, it would be awesome.
 

Don't want to see this ad? Sign up for anRPF Premium Membershiptoday. Support the community. Stop the ads.

xl97

Master Member
There has been so many different approaches and code and wiring diagrams posted...

it would be impossible to help you with you posting all that info one what you actually did/used.

Try changing the leds value/code/lines to the opposite of hi/low (whatever is there currently)
 

laf770

New Member
thanks for your reponse. tried that, but no luck. I get the same result. Soo frustrating. this is the last piece to my build and i was planning to hit up the comic con in Tampa today.
 

laf770

New Member
i used the original 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
}
}
 

Don't want to see this ad? Sign up for anRPF Premium Membershiptoday. Support the community. Stop the ads.

Cown

New Member
Hello everyone,

I'm having the exact same issue as laf770, how did you fix it?

I've tried editing the HIGH/LOW values, but nothing changes :-/

My lights are on when the helmet is closed, but when I open it, it flashes and then shuts off.. I'm lost for ideas.

Also, my servo is getting really hot, have i forgot to change something?

I'm using the following 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 = 0;
int pos = 10;
int pos1 = 130;
int servostatus = 1;
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(3);
// 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(pos1);
// 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(pos);
// myservo1.write(0);






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

Don't want to see this ad? Sign up for anRPF Premium Membershiptoday. Support the community. Stop the ads.

Top