so is it possible to get an arduino nano v3 and solder everything together to it and program it to move the face plate and light leds that are also powered by a separate power source? I'm trying to get all this done by May and it's starting to feel over my head o_o;; So far i have the uno and im still confused.
What is the reed switch needed for? Not sure why they are needed, can you explain why you want them for your build?
Ive tried this set-up and it works very well. really love the led power up sequence. I'm just thinking if it would be possible to power more LED using a seperate source yet control it using the arduino? will a relay work?
Also im thinking of using on/off switch to control the flight stabilizers, basically the flight stabilizers activate when the switch is on and the flight stabilizer will deactivate when the switch is offed. this is because i am thinking of using a reed switch to control the flight stabilizer and allowing easier control.
Im currently trying to pick up the arduino programming but if anyone can actually write it out fast it would be really helpful.
Reed switches aren't mandatory, some people use them as switches. You can put a magnet in one of your finger tips and touch it to where the reed switch is and it will "flip" the switch
I am loving this thread and have learned so much from it. There is one little thing that is niggling at me though. When Sinzz first started it I got the feeling it would be for the basic set up on open, close, eyes turn on and off when they should. Ok that was achieved in the first thread beautifully but it has strayed so far from the start. People like me who have no idea on electronics would get stuck once they have their set up the same as the first post. I know its better to teach your self how to get the last bits done but even after reading as much as I can its all above my head. I was wondering if through the knowledge of you tech types we could get the set up back on course to a finished piece for people like me.
Basically I propose that we say the eyes require 4 LEDs each, with an external power supply and power for the servos. I know its not as simple as that due to both the LEDs and servos needing different amounts of power to operate them but if we can pick an LED to use say the white 5mm LEDs and servos that you guys know would have power to lift the face plate (I am not really sure which would do the job but I am sure some one out there can pick us a standard to use).
It's great that all this info is being put here in one place but I know there must be lots of people out there hoping that the first post is made a bit more final so that those of us wanting our helmets to do what they should can
Maybe some could start a new thread for more advanced electronics, so people not getting confused with all that new ideas that come.
Andy
/***********************************************************************************************
* Just for those that want LEDs and Servos
*
* By: Chad Michaud
* Date: 22 March 2013
* Arduino 5v Pro
*******************************
Pin Guide
Arduino ----- Component
2 ----------- Button
3 ----PWM---- Servo Data
5 ----PWM---- LEDs via Transistor
*/
// Library Setup
#include <Servo.h> // Servo Library
// End Library Setup
// Global Variables
int helmPos = 0; // Stores servo position
int eyeBrightness = 0; // Stores how bright the eye LEDs are
int fadeAmount = 5; // Controls how fast the LEDs fade by
boolean hOpen = false; // Boolean to keep trak of helmets open/closed status
// End Global Variables
// Set Pin Location Constants
const int buttonPin = 2; // Sets pushbutton pin to pin 2
const int servoPin = 3; // Sets Servo Data pin to Arduino Pin 3
const int eyeLeds = 5; // Sets LEDs, via transistor, to Arduino Pin 5
// End Pin Location Constants
// Create Objects
Servo helmservo; // Create Servo object
// End Create Objects
void setup()
{
Serial.begin(9600); // This is just for Debugging
// Servo Setup
helmservo.write(helmPos); // Pre write the helmet to closed, this helps pervent servo twitch
// End Servo Setup
// LED Setup
pinMode(eyeLeds, OUTPUT); // Sets Pin for Output to the transistor controlling the LEDS
// End LED Setup
// Button Setup
pinMode(buttonPin, INPUT);
// End Button Setup
}
void loop()
{
if(digitalRead(buttonPin) == HIGH && hOpen == true) // If the button is pressed and the helmet is open.
{
closeHelm(); // Close the helmet
}
else if(digitalRead(buttonPin) == HIGH && hOpen == false) // If the button is pressed and the helmet is closed
{
openHelm(); // Open the helmet
}
}
void openHelm()
{
eyeBrightness = 0; // Set Eye brightness to off
analogWrite(eyeLeds, eyeBrightness); // Turn off LEDS
helmservo.attach(servoPin); // Sets pin for Servo Signal Wire
while(helmPos >=1) // While helm is not in it's up Position. May require tweaking
{
helmPos -= 10; // Decrease the position Variable. May require tweaking
helmservo.write(helmPos); // Write the new postition to the servo
delay(15); // Wait before running command again. May require tweaking
}
helmservo.detach(); // Dettach the Servo to prevent it from heating up.
hOpen = true; // Helmet is now open
}
void closeHelm()
{
helmservo.attach(servoPin); // Sets pin for Servo Signal Wire
while(helmPos <= 180) // While the helmet is not in it's down position. May require tweaking
{
helmPos += 10; // Increase the position Variable. May require tweaking
helmservo.write(helmPos); // Write the new postiion to the servo
delay(15); // Wait before running command again. May require tweaking
}
helmservo.detach(); // Dettach the Servo to prevent it from heating up.
// *******************First Blink on and off ************************
eyeBrightness = 255;
analogWrite(eyeLeds, eyeBrightness);
delay(100);
eyeBrightness = 0;
analogWrite(eyeLeds, eyeBrightness);
delay(100);
// *******************************************************************
// *******************Second Blink on and off*************************
eyeBrightness = 255;
analogWrite(eyeLeds, eyeBrightness);
delay(100);
eyeBrightness = 0;
analogWrite(eyeLeds, eyeBrightness);
delay(100);
// *******************************************************************
eyeBrightness = 255; // Sets eyes to full brightness
for(eyeBrightness = 255; eyeBrightness > 50; eyeBrightness = eyeBrightness - fadeAmount) // Now that the brightness is full, fade the brightness to 50(that may need to be changed) based on the fade amount
{
analogWrite(eyeLeds, eyeBrightness); // Write the brightness to the LED
delay(50); // Wait before you run again
}
hOpen = false; // Helmet is now closed
}
Ask and you shall revive, here is some some edited code that SHOULD set you on a path, at least code wise... note that I haven't tested this and I have had a few drinks so it may now be 100% but this will put you in the right ball park. My comments should help you understand it better... I'm FAR from an expert and I'm still learning but thought I would share
Code:/*********************************************************************************************** * Just for those that want LEDs and Servos * * By: Chad Michaud * Date: 22 March 2013 * Arduino 5v Pro ******************************* Pin Guide Arduino ----- Component 2 ----------- Button 3 ----PWM---- Servo Data 5 ----PWM---- LEDs via Transistor */ // Library Setup #include <Servo.h> // Servo Library // End Library Setup // Global Variables int helmPos = 0; // Stores servo position int eyeBrightness = 0; // Stores how bright the eye LEDs are int fadeAmount = 5; // Controls how fast the LEDs fade by boolean hOpen = false; // Boolean to keep trak of helmets open/closed status // End Global Variables // Set Pin Location Constants const int buttonPin = 2; // Sets pushbutton pin to pin 2 const int servoPin = 3; // Sets Servo Data pin to Arduino Pin 3 const int eyeLeds = 5; // Sets LEDs, via transistor, to Arduino Pin 5 // End Pin Location Constants // Create Objects Servo helmservo; // Create Servo object // End Create Objects void setup() { Serial.begin(9600); // This is just for Debugging // Servo Setup helmservo.write(helmPos); // Pre write the helmet to closed, this helps pervent servo twitch // End Servo Setup // LED Setup pinMode(eyeLeds, OUTPUT); // Sets Pin for Output to the transistor controlling the LEDS // End LED Setup // Button Setup pinMode(buttonPin, INPUT); // End Button Setup } void loop() { if(digitalRead(buttonPin) == HIGH && hOpen == true) // If the button is pressed and the helmet is open. { closeHelm(); // Close the helmet } else if(digitalRead(buttonPin) == HIGH && hOpen == false) // If the button is pressed and the helmet is closed { openHelm(); // Open the helmet } } void openHelm() { eyeBrightness = 0; // Set Eye brightness to off analogWrite(eyeLeds, eyeBrightness); // Turn off LEDS helmservo.attach(servoPin); // Sets pin for Servo Signal Wire while(helmPos >=1) // While helm is not in it's up Position. May require tweaking { helmPos -= 10; // Decrease the position Variable. May require tweaking helmservo.write(helmPos); // Write the new postition to the servo delay(15); // Wait before running command again. May require tweaking } helmservo.detach(); // Dettach the Servo to prevent it from heating up. hOpen = true; // Helmet is now open } void closeHelm() { helmservo.attach(servoPin); // Sets pin for Servo Signal Wire while(helmPos <= 180) // While the helmet is not in it's down position. May require tweaking { helmPos += 10; // Increase the position Variable. May require tweaking helmservo.write(helmPos); // Write the new postiion to the servo delay(15); // Wait before running command again. May require tweaking } helmservo.detach(); // Dettach the Servo to prevent it from heating up. // *******************First Blink on and off ************************ eyeBrightness = 255; analogWrite(eyeLeds, eyeBrightness); delay(100); eyeBrightness = 0; analogWrite(eyeLeds, eyeBrightness); delay(100); // ******************************************************************* // *******************Second Blink on and off************************* eyeBrightness = 255; analogWrite(eyeLeds, eyeBrightness); delay(100); eyeBrightness = 0; analogWrite(eyeLeds, eyeBrightness); delay(100); // ******************************************************************* eyeBrightness = 255; // Sets eyes to full brightness for(eyeBrightness = 255; eyeBrightness > 50; eyeBrightness = eyeBrightness - fadeAmount) // Now that the brightness is full, fade the brightness to 50(that may need to be changed) based on the fade amount { analogWrite(eyeLeds, eyeBrightness); // Write the brightness to the LED delay(50); // Wait before you run again } hOpen = false; // Helmet is now closed }
Also take a look at the button example under the Arduino software if your confused on how to set it up.