Go Down

Topic: Driving a servo using brushed ESC (Read 2 times) previous topic - next topic

AWOL

The example simply took the input from a pot (0..1023), mapped that range to an angle (0..180) and wrote that angle to a servo object.
Cut out the pot, substitute some angle constants, add a few "delay" calls, and your program is written.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

feliksayk

Could I ask you to please write that code for me? Like I said, I do not know this stuff and it's seriously confusing for me. You explain it to me as if it is very simple, and it probably is, I just don't know the basics.  ;D

AWOL

I don't normally, but it is the season of goodwill
[uncompiled, untested)
Code: [Select]


void loop ()
{
 myservo.write (30); // move servo 30 degrees
 delay (1000 * 9); // wait nine seconds
 myservo.write (0); //moves servo back 30 degrees
 delay (1000 * 30); // wait 30 seconds.
}

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

feliksayk

Thank you for this. How do you assign the pin for the servo signal though in the code? And does it have to be a digital or analog pin? I thank you once again. If you do not wish to answer, I guess I'll just have to spend some more time analyzing the tutorials.  ;)

feliksayk

#9
Dec 06, 2009, 11:09 pm Last Edit: Dec 06, 2009, 11:11 pm by feliksayk Reason: 1
Will this code work? I mean is it complete. Thanks

Code: [Select]

#include <Servo.h>

Servo myservo;  // create servo object to control a servo

int pos = 0;    // variable to store the servo position

void setup()
{
 myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop ()
{
 myservo.write (30);   // move servo 30 degrees
 delay (1000 * 9);     // wait 9 seconds
 myservo.write (0);    //moves servo back 30 degrees
 delay (1000 * 9);     // wait 9 seconds.
}

Go Up