Pages: [1]   Go Down
Author Topic: Robotic Arm (Lilypad powering Servo) Project Help!  (Read 4673 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey there!

So I've been attempting to tackle a confusing issue today and have had no success thus far. I figure this is the best place to ask questions about the Lilypad Arduino. In essence I am working on a project to create a wearable robotic arm. The electronics are basic; it involves a flex sensor that controls the degrees of a medium servo motor (from 15 to 180 degrees).

I got my code to work perfectly well when using the Arduino UNO, the flex sensor controls the servo perfectly well. When I place the very same code on my Lilypad I get all sorts of odd results. It is fidgety and the servo motor constantly scrolls through 15-180 degrees rather than follows the data provided by the flex sensor.

Code:

Code:
#include <Servo.h>
Servo servo1;
const int flexpin = A2;

void setup() {

  Serial.begin(9600);
  servo1.attach(5);

}

void loop() {

  int flexposition; // Input value from the analog pin.
  int servoposition; // Output value to the servo.

  flexposition = analogRead(flexpin);

  servoposition = map(flexposition, 300, 600, 15, 180);

  servoposition = constrain(servoposition, 15, 180);

  servo1.write(servoposition);

  Serial.print("sensor: ");

  Serial.print(flexposition);

  Serial.print("servo: /n");

  Serial.print(servoposition);


  delay(10);

}




Any idea what's going wrong here? Thanks in advance!!!
Logged

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 105
Posts: 4660
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've never used a Lilypad, so I can't answer with any specifics, but your headline snippet "Lilypad powering Servo" got my attention.... do you mean that literally, ie the power for the servo comes from the LP, or do you mean more loosely that the control comes from the LP?

If you mean the power (and I don't even know if an LP has a 5V out like a Uno  smiley-cool ), then that may be the problem, and the servo's not getting enough current. Servo funnies often seem to stem from current issues, where the user thinks all is cool just because the voltage is correct.

Providing a servo's 5V from an Uno is marginal: if it's even possible on an LP it might be totally impractical.

So, if you haven't already done so, give the servo its own 5-6V supply, with its ground tied back to the LP's.

If you are already doing it that way, then right now I have no further ideas....
Logged

The Elders of the Internet know who I am
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah, the lilypad is powering the servo as well.. I'm using a 3.7v battery with the lilypad. I've been trying to use a step up breakout to make the voltage 5v.... yet it is still not working >->.

I'll try giving the servo power from another source and see what that gives me... thanks for the reply!

Logged

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 105
Posts: 4660
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You might be getting 5V but at too little current... so yep, give the external supply a try, and one way or another you'll get an idea of what's what.
Logged

The Elders of the Internet know who I am
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Worked perfectly with its own power supply smiley.. thank you so much for your help!
Logged

Pages: [1]   Go Up
Jump to: