Blinking LEd controlled by servo state

I want to install a simple led light to tell me what is going on with my servo..

When positionof the servo is 0, the LED = OFF
When servo is moving from 1 to 89 degrees, LED needs to blink.
When servo has reached 90 degrees, led should be ON.

Servo is starting to move from 0 to 90 when I push the button.
It stays at that position until I push same button again and then moves back to position "0".

Anyone?

How long do you expect the travel to take from 0 to 90 degrees?

Sikter:
Anyone?

Was there a question?

johnwasser:
How long do you expect the travel to take from 0 to 90 degrees?

2 or 3 sec

Sikter:

johnwasser:
How long do you expect the travel to take from 0 to 90 degrees?

2 or 3 sec

In order to slow the servo down that much you will need to move it in small increments an insert delays. That should give you an opportunity to blink the LED. At 30 to 45 degrees per second a good blink rate might be every 10 degrees:

for (int angle = 0; angle <= 90; angle++)
    {
    MyServo.write(angle);
    digitalWrite(LEDPin, (angle/10) % 2);
    delay(25);  //delay 1/40th of a second
    }

PeterH:

Sikter:
Anyone?

Was there a question?

You're right! There was not question...
I need some direction to get started. I don't know how to aproach the problem.

johnwasser:

Sikter:

johnwasser:
How long do you expect the travel to take from 0 to 90 degrees?

2 or 3 sec

In order to slow the servo down that much you will need to move it in small increments an insert delays. That should give you an opportunity to blink the LED. At 30 to 45 degrees per second a good blink rate might be every 10 degrees:

for (int angle = 0; angle <= 90; angle++)

{
    MyServo.write(angle);
    digitalWrite(LEDPin, (angle/10) % 2);
    delay(25);  //delay 1/40th of a second
    }

So simple was that. Thank you very much.
Will the LED stay ON when angle = 90 and servo stops?

Sikter:
So simple was that. Thank you very much.
Will the LED stay ON when angle = 90 and servo stops?

(90 / 10) % 2 = 1

1 means HIGH

Write a sketch that reads the pushbutton and detects when the button changes from 'not pressed' to 'pressed'.

Write a sketch that flashes an LED, based on the 'blink without delay' example.

Provide a suitable power supply for your servo, remember to connect the earths and use the servo library to sweep the servo through the range of positions you want at the speed you want.

Once you have all the elements, you'll use the button code to trigger the start of each movement sequence, flash the LED while the movement is in progress and stop flashing when the movement is complete.

Thanks,
If I want to place my LED in another room, I need long leads.
It will probably give me a trouble.
So I need separate power supply for the LED. I'm going to use a transistor as a switch.
Probably some resistors too and again connect ground with
Arduino.
Is this correct?

Are you using ordinary small low power LEDs? They don't draw much current at all so they will cause very little voltage drop. Unless you're trying to run wires over hundreds of yards I wouldn't have thought you would have any problems. And if you do run the lines so far that voltage loss is a problem, given that the resistance of the lines is known and constant, you can just subtract that resistance from your current limiting resistors for the LEDs.

PeterH:
Are you using ordinary small low power LEDs? They don't draw much current at all so they will cause very little voltage drop. Unless you're trying to run wires over hundreds of yards I wouldn't have thought you would have any problems. And if you do run the lines so far that voltage loss is a problem, given that the resistance of the lines is known and constant, you can just subtract that resistance from your current limiting resistors for the LEDs.

Thank you!
It makes perfect sense. I am using 4 ordinary 5mm LEDs.
We just discussed my first LED, which will tell me about Servo's actions.

My second LED will tell me when the effect pedal is ON.
I intend to connect it according to diagram below.
I will use same power supply both for the pedal and Arduino ( 9V DC)

IS THIS SAFE. Will it work?

Uploaded with ImageShack.us

i think u can do something easy, but need a little hardware modification, you have to open your servo carefully and solder a wire to the middle pin of the potentiometer, then u have to "calibrate" your sketch using analogRead() function read the 0 degree state of the pot and the 90 degree state, use the map function to map your result to a variable call "time" and this variable control the blink speed of your led.

and use if == 0 and if == 90 to set de led on all the time.

i hope this help u :smiley:

Sikter:
IS THIS SAFE. Will it work?
[/URL]

The LED output on D3 looks fine, as long as you choose the appropriate rating of current limiting resister R.

On the input side to A3, I have no idea what sort of signal that supplies. You need to ensure it is always within the voltage range defined by Arduino ground and 5V pins. If you achieve that, it won't damage the Arduino.

Thank you guys!
I think all my questions have been answered and while I'm waiting for components to arrive I can draw my detail diagram,
mechanical drawings and do some reading. I'll let you know how it went.
I'll probably struggle to get my finale sketch to work perfectly but it's a part of the game.
sikter

Just a little update:
Aurdino arrivef
tested connection with my DOD digital delay pedal and it worked fine.
This pedal gave only 1.6V from the spot marked on my diagram above.
I used another spot to soldier my signal wire which reads 3.3 V.
I'll test my DS-1 pedal tonight.

Still waiting for my servo to arrive but I don't have
any doubts about that. Nothing unknown on that part.

Thank you guys a lot!
sikter