06/09/13
Arduino - Control ESC/Motor (Arduino Code)
Fun Projects of Vari
Sidebar
Contact me
The Unpublished
search
Arduino - Control ESC/Motor (Arduino Code)
Summary
OpenCV - Canny Edge,
Android - An example a
This is only the Arduino sketch for the tutorial "Arduino - Control ESC/Motor Tutorial
[[Link] ". This is a tutorial of how to control an electronic speed control (ESC) [[Link]
Android IOIO - Listen for
Android IOIO - motor co
and brushless motor
[[Link] using an Arduino [[Link] .
Arduino - Control
17
Arduino - Control
33
Arduino - Control
/* * This code is in the public domain. * (Do whatever you want with it.) */ // Need the Servo library #include <Servo.h> // This is our motor. Servo myMotor; // This is the final output // written to the motor. String incomingString;
C# - Using the Comma
PowerSwitch Tail
Android App - Ma
Maximum Data Rate of
C# Text Messages by E
Multiplatform Project
Send Email C# - Exam
// Set everything up void setup() { // Put the motor to Arduino pin #9 [Link](9); // Required for I/O from Serial monitor [Link](9600); // Print a startup message [Link]("initializing"); }
Computer Projects
[Link] - Add Member
MS SQL Server 2
Android - Use we
void loop() {
[Link]/2012/06/[Link] 1/7
06/09/13
Arduino - Control ESC/Motor (Arduino Code)
Fill PDF forms in
The RC Car Hack - App
The RC Car Hack - Part
// If there is incoming value if([Link]() > 0) { // read the value char ch = [Link]();
Send feedback
The RC Car Hack - Part
The RC Car Hack - Part
TVS diode and the dea
Arduino Vending
(Tablet + Elm327) / Blu
Project 1 - Arduino Acce
/* * If ch isn't a newline * (linefeed) character, * we will add the character * to the incomingString */ if (ch != 10){ // Print out the value received // so that we can see what is // happening [Link]("I have received: "); [Link](ch, DEC); [Link]('\n'); // Add the character to // the incomingString incomingString += ch; } // received a newline (linefeed) character // this means we are done making a string else { // print the incoming string [Link]("I am printing the entire string"); [Link](incomingString); // Convert the string to an integer int val = [Link](); // print the integer [Link]("Printing the value: "); [Link](val); /* * We only want to write an integer between * 0 and 180 to the motor. */ if (val > -1 && val < 181) { // Print confirmation that the // value is between 0 and 180 [Link]("Value is between 0 and 180"); // Write to Servo [Link](val); }
[Link]/2012/06/[Link]
2/7
06/09/13
Arduino - Control ESC/Motor (Arduino Code)
// The value is not between 0 and 180. // We do not want write this value to // the motor. else { [Link]("Value is NOT between 0 and 180"); // IT'S a TRAP! [Link]("Error with the input"); } // Reset the value of the incomingString incomingString = ""; } } } Posted 11th June 2012 by Sean OBryan
5
View comments
Wilhelm Kuckelsberg October 11, 2012 at 4:57 AM Hello, I'm a little desperate. I want to settle with my 4 brushless Duemillenova. 3 motors work that is no longer the fourth. ESC and motors are teste and OK. here is mey code: #include #include Servo rotor_1; Servo rotor_2; Servo rotor_3; Servo rotor_4; #define PINESC1 5 #define PINESC2 6 #define PINESC3 10 #define PINESC4 11 #define ARM_TIME 10000 typedef enum { STARTROTOR1, STARTROTOR2, STARTROTOR3, STARTROTOR4, } rotation_t; int rotorSpeed = 0; int rotorMillis = 0; unsigned long currentMillis = 0;
[Link]/2012/06/[Link]
3/7
06/09/13
Arduino - Control ESC/Motor (Arduino Code)
void setup() { [Link](9600); rotor_1.attach(PINESC1); rotor_2.attach(PINESC2); rotor_3.attach(PINESC3); rotor_4.attach(PINESC4); arm_esc(ARM_TIME); } void loop() { ReadKeybord(); start(); currentMillis = millis(); [Link]("Current Millis - ");[Link](currentMillis); } void start() { static rotation_t rotation = STARTROTOR1; static int wait = 1; static unsigned long newMillis = 0; switch(wait) { case 1: newMillis = currentMillis; wait = 2; break; case 2: if (currentMillis - newMillis >= 25) { [Link]("New Mills - ");[Link](newMillis); switch(rotation) { case STARTROTOR1: rotor_1.writeMicroseconds(rotorMillis); [Link]("CW1 MS - ");[Link](rotorMillis); rotation = STARTROTOR2; break; case STARTROTOR2: rotor_2.writeMicroseconds(rotorMillis); [Link]("CCW1 MS - ");[Link](rotorMillis); rotation = STARTROTOR3; break; case STARTROTOR3: rotor_3.writeMicroseconds(rotorMillis); [Link]("CW2 MS - ");[Link](rotorMillis); rotation = STARTROTOR4; break; case STARTROTOR4: rotor_4.writeMicroseconds(rotorMillis); [Link]("CCW2 MS - ");[Link](rotorMillis); rotation = STARTROTOR1; break; } wait = 3; }
[Link]/2012/06/[Link] 4/7
06/09/13
Arduino - Control ESC/Motor (Arduino Code)
break; case 3: wait = 1; break; } } void arm_esc(int ArmTime) { delay(ArmTime); [Link]("Sending lowest throttle Motor 1"); rotor_1.writeMicroseconds(1000); delay(2000); [Link]("Sending lowest throttle Motor 2"); rotor_2.writeMicroseconds(1000); delay(2000); [Link]("Sending lowest throttle Motor 3"); rotor_3.writeMicroseconds(1000); delay(2000); [Link]("Sending lowest throttle Motor 4"); rotor_4.writeMicroseconds(1000); delay(2000);
[Link]("Low throttle sent"); } void ReadKeybord() { int key = 0; if([Link]() > 0) { key = [Link](); switch(key) { case '2': rotorMillis = mapSpeedToMicrosec(rotorSpeed += 1); [Link](" - Speed steigern - ");[Link](rotorSpeed); break; case '8': rotorMillis = mapSpeedToMicrosec(rotorSpeed -= 1); [Link](" - Speed senken - ");[Link](rotorSpeed); break; case '5': rotorMillis = mapSpeedToMicrosec(0); rotorSpeed = 0; [Link](" - Stop - ");[Link](rotorSpeed); break; } } } int mapSpeedToMicrosec(int speed) { int _MS = 0;
[Link]/2012/06/[Link] 5/7
06/09/13
Arduino - Control ESC/Motor (Arduino Code)
_MS = map(speed, 0, 150, 1000, 2500); [Link](" - setSpeed Millis - ");[Link](_MS); return(_MS); } Reply Replies Sean OBryan October 12, 2012 at 2:34 PM I'll take a look tonight. Are you using a shield? Just posted another example. It uses the Servo library but may help as another example. [Link] Reply
proton_gt March 11, 2013 at 8:32 PM i have test with my RC CAR esc but it only can move forward when i sent "val" above 90. it just stop and not move reverse when i sent "val" below 90. how can i move it reverse?? Reply
Maciej Kost March 22, 2013 at 9:49 AM This comment has been removed by the author. Reply
Maciej Kost March 22, 2013 at 9:50 AM To turn on the ESC with this program. Fits 10 and nothing happens Reply
[Link]/2012/06/[Link]
6/7
06/09/13
Arduino - Control ESC/Motor (Arduino Code)
E n t e ry o u rc o m m e n t . . .
Comment as: Google Account Publish Preview
[Link]/2012/06/[Link]
7/7