two input switches to control one servo: A little advice needed.

Before we begin,

Yes, I joined this forum just to ask this question.
Yes, I will likely stick around this forum after this is answered.
Yes, I am extremely new to programming but have some simple experience, and friends who can help.
Yes, I know how to solder.
Yes, I know basic electrical and electronics principals.
Yes, I am likely over-complicating my project but that is why I am asking!

I want to describe my idea BEFORE I describe the actual application. I do not want my application changing your opinions before you hear what I am trying to do...

I am not saying which Arduino (or PICAXE or STAMP or whatever) processor I am using, because I would like you readers to suggest the least complicated and lowest cost to do what I describe.

When limit switch L1 (the actual nature of this limit switch is not-yet important) is activated, I need a Servo to move to a certain degree of rotation (the actual function of this servo output is also not-yet important), until L1 is no longer activated. When L2 is activated, I need a different degree of rotation on the same servo. If BOTH L1 AND L2 are activated, I need a third degree of rotation ON THE SAME SERVO. I would like to easily be able to adjust these degrees of rotation independantly from each other as I have no idea what they will finally be.

I appologize for being so cryptic about my application but I have had a number of people tell me "you're wasting your time" or "it can't be done" when I KNOW it can! I just dont know the most efficient way of doing it and that is what I am asking for.

After I get a couple answers, I will gladly describe the application.

Thank you, in advance,

Michael, from DieCastoms

Not quite sure what your question actually is.
The operation you describe is almost trivial to implement, requiring only four lines of code in the loop() function.

This is quite simple. You are moving l1 until it no longer activates at a certain threshold. So I guess you could just do{servo.write(CurrentDegrees+Value); Value +=1} while result < threshold;

Mike is right, but if you are using a PICAXE or STAMP, you're in the wrong place.

Holy crap, I wasn't expecting replies so fast! Thank you! I'm excited now :stuck_out_tongue:

Ok, I am building a large radio control truck. I am powering the drive motor of this truck with a SyRen 1x50 motor controller. This controller allows one servo input (from a standard, average Radio Control recieve) to control speed in both directions, and it allows a second servo input to adjust the top speed. A 50% input from the second servo will mean that you will only get 50% speed from the full range of travel from the first servo!

I want to add tilt switches or maybe an actual accelerometer to my truck so that if it is on a steep incline (this one is more useful for when going down hill, not up) it will automatically slow down, or if it is tipped to the side too far, it will automatically slow down.

Now that you know what my application is, I will take suggestions on what else i could use the microcontroller for in this project, because I would hate to spend $30 bucks just for a little tilt-sensing. I was thinking of using the microcontroller for adding LED lighting (headlights, tail lights, brake lights, turn signals, controlled from the throttle channel of the Rx) and maybe even MP3 playback..

Any ideas?

Mike, from DieCastoms.

To save money you may get a modern device RBBB kit or maybe a sparkfun arduino mini. They are cheaper and smaller to fit on a mobile platform. But I still suggest you get a regular arduino UNO so you can prototype your project in your home and only assemble the compact cheaper board after your project completes the prototype phase. I can see your project will need an accelerometer and do a running average of the reading and comparing with "level" redings. If the average goes beyond level you reduce the speed of your motor to prevent the rc car from tipping over. Having flashing led is almost trivial too. You can even log your data and determines a max speed for each angle of inclination so you can drive your rc car to max safe speed with the data, how about at? Of course MP3 costs extra money.

For the tilt sensor I would have thought you could just use a lightly-damped pendulum with a limit switch. Alternatively, a design I've seen used for impact sensors is a cone with a steel ball in it, that closes two contacts as long as stays at the bottom of the cone. Once the G exceeds some threshold, the ball rolls and breaks the circuit.

I'm not familiar with that speed controller. Does it simulate inertia? If not, that's something that would be feasible for the Arduino to do based on a wheel speed sensor, so that you get scale realistic acceleration and deceleration.

For the amount of effort involved in making something like this, I hope you'll end up with a realistic engine sound emulator too. :slight_smile:

not sure if any of you care to know or not, but.. here's an update on my project..

I ordered the motor controller on March 29th. It was nice of the company I ordered it from to never tell me that they were out of stock and that it wouldn't be shipped out for at least two weeks after I ordered it.. I had to email and wait a week for a response..

When the controller ever gets here, I will post another update.

Mike.