This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

  • 3 voto(s) - 3 Media
  • 1
  • 2
  • 3
  • 4
  • 5
Proyecto
#41
El código, perdón.
  Responder
#42
Puedes depende del tutorial que utilice un código distinto. Por ejemplo para este tutorial (http://androidcontrol.blogspot.com.es/20...ntrol.html) utilizo este código y pongo los cables según el diagrama de la página, pero no se si el problema es del servo que es el 9g azul de Ebay :
#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
int motor = 0;

void setup()
{
Serial.begin(9600); // initialize serial:
myservo.attach(9); // attaches the servo on pin 9 to the servo object

Serial.print("Arduino control Servo Motor Connected OK");
Serial.print('\n');
}

void loop()
{
// if there's any serial available, read it:
while (Serial.available() > 0) {

// look for the next valid integer in the incoming serial stream:
motor = Serial.parseInt();

// do it again:
pos = Serial.parseInt();

// look for the newline. That's the end of your sentence:
if (Serial.read() == '\n') {

myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position

// print the three numbers in one string as hexadecimal:
Serial.print("Data Response : ");
Serial.print(motor, DEC);
Serial.print(pos, DEC);

}
}
}

//for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
//{ // in steps of 1 degree
// 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
//{
// myservo.write(pos); // tell servo to go to position in variable 'pos'
// delay(15); // waits 15ms for the servo to reach the position
//}


//val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
//val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
//myservo.write(val); // sets the servo position according to the scaled value
//delay(15);
  Responder
#43
Después del 9 pon 600 y 1500 así:
myservo.attach(9,600,1500);

Recuerda que en el servo azul el amarillo tiene q ir al 9, el rojo a 5V y el negro/marrón a GND.

Mira este video: https://www.youtube.com/watch?v=CGlIpfgqPMM
Y el de las apps q te deje en anteriores respuestas; sii no te funciona la App te la puedes hacer tú mismo.
  Responder
#44
el problema del video que me has pasado es que no explica como hacer eso mismo pero mediante el modulo BT y con una APP. Vi ese video y me sirvió para coger la idea de mover el servo con un potenciometro, cosa que ya hice y funciona perfectamente, el problema es cuando intento hacer funcionar el servo mediantel el BT. No encuentro la manera de que funcione y ya he visto varios tutoriales, no se si es algo que estoy haciendo mal o que jajaja
  Responder
#45
¿Pero funciona lo del "myservo.attach(9,1500,600)"?
Si no hazte la App con el video que te puse y en vez de controlar un led controlas el servo con varios botones.
(31-10-2015, 11:16 PM)Iván escribió: Si quieres controlarlo con el móvil con el modulo BT, te puedes hacer la App tu mismo en Mit App inventor la pones en el móvil y cargas el programa correspondiente. Mira estos videos:
https://www.youtube.com/watch?v=ftXTtba_CjU
https://www.youtube.com/watch?v=S8q1vbVMV2Q
https://www.youtube.com/watch?v=j-cUDfmtq5g

Son el 2º y el 3º
  Responder
#46
Voy a probar ahora si cambiando el código funciona.
#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
int motor = 0;

void setup()
{
Serial.begin(9600); // initialize serial:
myservo.attach(9,1500,600); // attaches the servo on pin 9 to the servo object

Serial.print("Arduino control Servo Motor Connected OK");
Serial.print('\n');
}

void loop()
{
// if there's any serial available, read it:
while (Serial.available() > 0) {

// look for the next valid integer in the incoming serial stream:
motor = Serial.parseInt();

// do it again:
pos = Serial.parseInt();

// look for the newline. That's the end of your sentence:
if (Serial.read() == '\n') {

myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position

// print the three numbers in one string as hexadecimal:
Serial.print("Data Response : ");
Serial.print(motor, DEC);
Serial.print(pos, DEC);

}
}
}

//for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
//{ // in steps of 1 degree
// 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
//{
// myservo.write(pos); // tell servo to go to position in variable 'pos'
// delay(15); // waits 15ms for the servo to reach the position
//}


//val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
//val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
//myservo.write(val); // sets the servo position according to the scaled value
//delay(15)

Sería así el código según me has dicho no?

Vale, acabo de probarlo como tu me has dicho y parece que funciona, voy a testearlo bien por si hubiera algún problema, muchas gracias crack Sonrisa!!
  Responder
#47
De nada! Para eso estamos.
Enséñanos un video o alguna foto del acabado final. Guiño
  Responder