Hello, I'm requesting some help on issue found below. I'll gladly respond to any request for further details.
Summary:
Expected-Servo moves when using myservo.write on an Arduino Leonardo based board.
Actual-Servo does not react to write command.
Details:
I'm trying to drive hobby servos from an TKLCD aka Arduino Leonardo with 16x2 LCD (from now defunct? Tinkerkit) as seen here TKLCD The board is connected via USB directly to a laptop, no other Arduinos present.
No issues using the LCD screen.
No issues blinking the built in LED with the sample IDE "Blink" sketch.
I can successfully upload and run the the sketch seen below. The LCD will display the changing servo pos(position) values, but I get no response from the servo.
The board has D6, D5 and D12 as digital in/outs you can see D12 at the bottom right on this pic.
Is this even viable? Am I using the wrong connection? The servo is a std hobby type HS-422 servo connected to "D6" on the board. I have tried D5 and D12 with same result, I've also tried different servos (same type, it's all I have) with same results.
This is my first exposure to Arduino so I may be missing something quite obvious.
#include <Wire.h>
#include <LiquidCrystal.h>
#include <TKLCD.h>
//TKLCD_Serial lcd = TKLCD_Serial(); // when connecting to TKLCD over Serial
TKLCD_Local lcd = TKLCD_Local(); // when programming a TKLCD module itself
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup() {
lcd.begin();
myservo.attach(D6);
lcd.clear();
lcd.print("Hello World!");
lcd.setCursor(0,1);
lcd.print("Again!");
}
void loop() {
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
lcd.setCursor(8,1);
lcd.print(pos);
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
lcd.setCursor(8,1);
lcd.print(pos);
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
How is the servo connector connected to the LCD board?
They have a connector with red, wht, black wires. The red should be to +5, the black to Gnd and the white wire to D6.
So, what's the scoop there?
When D6 is sending PWM pulses you should be able to see a faint light from an LED
D6------A_K-----220Ω-----Gnd
[There's a possibility that the LCD board can't provide adequate current to the servo.]
The servo is plugged directly to the board (std. 3 wire/color servo plug as you described) , can't find a schematic for this board so I don't know which is +5.
I'll go to my breadboard and will connect a LED to the "D" output and report back.
MarkT:
No, the servo power should not be connected to the Arduino 5V,
but to an external power source capable of at least 1A, possibly more.
The most common problem people have with servos is inadequate power.
We're assuming D6 doesn't have any other connection on that board(s). Can
you confirm that?
The only connection to the board is micro USB and the servo plug directly to "D6". Since the board only provides 3 analog and 3 digital connections I can only assume that nothing else is internally "driven" from D6.
I can try uploading sketch unplugging USB and then powering the board from a higher current 5V source (which I need to source) if servo power is a concern. For this board I believe I would have to go in via the 2 power pins on the Serial connection (unlike full fledged Leonardo this one does not have a separate power plug).
Would this approach take care of your power concerns?
Orangejoe:
The servo is plugged directly to the board (std. 3 wire/color servo plug as you described) , can't find a schematic for this board so I don't know which is +5.
Then get a voltmeter.
Which is +5, Gnd, signal - it's not trivial, knowing what's what here is crucial.
I used a LED to figure out the polarity and to test the basic blink sketch from D6.
I also acquired a micro servo (which shows some signs of life when connected to the board) so it seems there is just not enough juice to drive a full sized hobby servo.
This is as far as I've got (little "free" time this past few weeks) but wanted to give the forum the quick update.
I'll put together a battery pack and will power the servo from it using the PWM from the board, which I'm confident will work.
@RunawayPancake, yes a multimeter is fun-damental, all my equipment is in storage a few thousand miles away so I've resisted buying it all again. I might just have to bite the bullet.
All in all, it seems that for ~$7 these Leonardo-like, Italy made 16x2 LCD boards are a good deal for the hobbyist.