loading
Hey guys, I'm back with another instructable. This is about RC speed controllers. What this will do is allow you to test out your speed controller in the Arduino world using Serial, then you write the values down and can use them for your projects. 







Submitted by Newton Labs for the Instructables Sponsorship Program

Step 1: Setup

All you need to do is hook up your speed controller to your Arduino, red(s)->+5 black/brown(s)->GND yellow/white(s)->10 and/or 9.

Step 2: Programming

// If you need any help feel free to PM me (simonfrfr) or email me
// at newtonlabs@bellsouth.net
String readString;
#include <Servo.h>
Servo myservo;  // create servo object to control a servo
Servo myservo2; // create second servo object
const int left = 10; // left motor's pin on arduino
const int right = 9; // right motor's pin on arduino
void setup() {
  Serial.begin(9600);
  Serial.println("servo-test-22-dual-input"); // so I can keep track of what is loaded
}

void loop() {
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string
    if (readString == "l") // acfivates left servo only
    {
      myservo.attach(left); // writing both to left motor
      myservo2.attach(left);
    }
        if (readString == "r") // activates right servo only
    {
      myservo.attach(right); // writing both to left motor
      myservo2.attach(right);
    }
        if (readString == "b") // activates both motors
    {
      myservo.attach(left); // writing to left motor
      myservo2.attach(right); // writing to right motor
    }
    int n = readString.toInt();  //convert readString into a number

    // auto select appropriate value, copied from someone elses code.
    if(n >= 500)
    {
      Serial.print("writing Microseconds: "); // serial display
      Serial.println(n); // number
      myservo.writeMicroseconds(n); // writes to ports
      myservo2.writeMicroseconds(n);
    }
    else
    {  
      Serial.print("writing Angle: "); // serial display
      Serial.println(n); // number
      myservo.write(n); // writes to ports
      myservo2.write(n);
    }

    readString=""; //empty for next input
  }
}

Step 3: Enjoy!!!

Go to Serial monitor and input number values and you can try different frequencies for different RC speed controller rates. Enjoy! Feel free to ask any questions or comment on my coding.
Nice tutorial, however when I try to use it on the same board, the board acts that it has lost radio signal and activates the failsafe, how did you get past this?
Oh, the switches on the controller need to be flipped in the right order. (just try different switch combinations)

About This Instructable

22,401views

87favorites

License:

Bio: Hey YOU! Yeah, I'm talking to you who is reading this. Send me ideas for instructables, like things that you are wondering how to ... More »
More by simonfrfr:DIY Spectrometer) Explore the Unknown -> Zombie Attack! Easy to build! Newton Labs Projects Arduino Guide (2012) 
Add instructable to: