Go Down

Topic: Help with servomotors, programming and connection with my Mac  (Read 620 times) previous topic - next topic

SteveDeutschland

Hello, I am new in this and i just started learning Arduino`s language to make a robot gripper but I need to know how can I program the servos.  Also my project includes Wi-fi controlling and I also don`t know how to do it.

Thanks.

zoomkat

Simple servo test code you can use to see if you can control your servo.

Code: [Select]

//zoomkat 7-30-10 serial servo test
//type servo position 0 to 180 in serial monitor
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h>
Servo myservo;  // create servo object to control a servo

void setup() {
  Serial.begin(9600);
  myservo.attach(9);
  Serial.println("servo-test"); // 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
    int n = readString.toInt();  //convert readString into a number
    Serial.println(n); //so you can see the integer
    myservo.write(n);
    readString="";
  }
}

Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

PaulS

Quote
but I need to know how can I program the servos
You can't. Servos can be controlled. Microprocessors can be programmed.

Quote
Also my project includes Wi-fi controlling and I also don`t know how to do it.
Then, you are going to have real problems completing the project.
The art of getting good answers lies in asking good questions.

JimboZA

I can't help at all on the WiFi side, and have never used a Mac in my life.

But controlling a servo is dead simple: start here and see how you get on. That should get you started, then come back with specific questions if you need to.
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0

Go Up