Hi
Can i use arduino to control a stepper motor to move 90 degrees when it senses a current of another circuit and when current is turned off it returns to 0 degrees. What i got is when i turn my headlights on it will open up a fold away light bar and when lights are turned off it will fold away, can you help me.
You most likely will not need to sense current in a circuit to determine if the lights are on. With the activation of the lights switch, voltage is applied somewhere. Sensing that voltage is probably what you want to do. Much simpler to do than sensing current.
Stepper motors don't move to any position (including 0 or 90 degrees) without first establishing a starting (home) position and then applying steps to the motor to get it to the desired position. With a stepper, you have to to know where it currently is and then step it to a desired destination. It can be done with a stepper but using one only complicates the project.
A servo would work fine but you'd have to find one with enough torque and that may be expensive.
However, there are plenty of low cost dc gear motors that pack alot of power for the dollar. There are oodles of used or new automotive electro-mechanical devices that could be used, often cheaply available.
You probably have your heart set on using an Arduino but an Arduino is much too high tech for such a project. With a gearmotor, a couple of limit switches, a couple of relays, a control switch and wire connectors, a fuse, etc., your project could reach fruition.
As Weedpharma stated, the electronics (or electrical) is easy. The rest will be a challenge. Could be fun though.
I agree. It is much easier to simply tap across the headlights contacts and step that voltage down with a voltage divider. Alternately, you can use the +12V headlights power to drive an opto-isolator with a pullup resistor to +5V on the output Collector.
When the lights are on, the Arduino will see a LOW on the digital input connected to the output transistor's collector at the pullup resistor.
I'd use a regular-old DC motor with a gear or pulley system to slow it down to a reasonable speed. Then, you can either use a mechanical stop, or a combination of a limit-switches and a mechanical stop.
I'm not sure if my power windows have any kind of limit switch, I think it's just a mechanical stop and if you hold the switch down current continues to flow through the motor and it "tries" to keep moving.