Go Down

Topic: Beginner's Robotic Arm (Read 7 times) previous topic - next topic

zoomkat

Quote
what i am to send at your code in order for me to trigger a specific servo.. im not going to be sending servo positions, il only be sending a specific character then my receiver arduino would process it.


I would think you could use a series of "if" or "case" statements to evaluate the character received by the arduino, and send a value to the appropriate servo based on the received character. 
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

pao_wikhan

ok! will try that..thanks!!

pao_wikhan

#17
Jul 12, 2011, 06:12 pm Last Edit: Jul 13, 2011, 06:24 pm by pao_wikhan Reason: 1
@zoomkat
im not getting anything out of the serial monitor, also my servos wont run. thanks!

P.S.

im using a PIC16F628A as my transmitter programmed using flowcode v4 and arduino decimilla 168 as my receiver. over 5812A UHF transceiver.http://www.e-gizmo.com/KIT/images/UHF/5812A%20Tech%20Manual.pdf

pao_wikhan


Quote
can someone help me recode my code???im not getting any results, even for just one servo port via serial comm. i dont get it, why i can let an LED be high but moving a servo, i cant..help pls! tnx!


Some servo test code I use for testing two servos:

Code: [Select]
// zoomkat 11-22-10 serial servo (2) test
// for writeMicroseconds, use a value like 1500
// for IDE 0019 and later
// Powering a servo from the arduino usually DOES NOT WORK.
// two servo setup with two servo commands
// send eight character string like 15001500 or 14501550

#include <Servo.h>
String readString, servo1, servo2;
Servo myservo1;  // create servo object to control a servo
Servo myservo2;

void setup() {
  Serial.begin(9600);
  myservo1.attach(6);  //the pin for the servo control
  myservo2.attach(7);
  Serial.println("servo-test-21"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    delay(1); 
    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      readString += c; //makes the string readString
    }
  }

  if (readString.length() >0) {
      Serial.println(readString); //see what was received
     
      // expect a string like 07002100 containing the two servo positions     
      servo1 = readString.substring(0, 4); //get the first four characters
      servo2 = readString.substring(4, 8); //get the next four characters
     
      Serial.println(servo1);  //print to serial monitor to see results
      Serial.println(servo2);
     
      int n1; //declare as number 
      int n2;
     
      char carray1[6]; //magic needed to convert string to a number
      servo1.toCharArray(carray1, sizeof(carray1));
      n1 = atoi(carray1);
     
      char carray2[6];
      servo2.toCharArray(carray2, sizeof(carray2));
      n2 = atoi(carray2);
     
      myservo1.writeMicroseconds(n1); //set servo position
      myservo2.writeMicroseconds(n2);
    readString="";
  }
}




i get your code now...im using 3 servos so  i have to change this char carray1[6]; to char carray1[9]; ???am i right????

AWOL

Quote
im using 3 servos so  i have to change this char carray1[6]; to char carray1[9]; ???am i right????

Not sure I follow your logic there - can you post your code?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up