Pages: [1]   Go Down
Author Topic: [HELP] java + arduino and servo  (Read 429 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some body help me please..
I am a nubi in arduino..
I need to use an arduino uno board to control 2 motor servo,with java application,
I had bought the arduino and the servo, is there somebody can help me with source code on arduino and java?
And how i put the two servo on arduino board?  smiley-confuse
Regards;
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24317
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you looked at Processing?
Have you looked at any of the worked examples?

(I deleted your other post on this subject to save other people wasting their time)
Logged

"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.

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

Of course i had, but i not too understand, sorry for my useless post,
 i just wanna to understand about an arduino with java and motor servo..

Logged

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8911
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Simple servo test code for servo testing.

Code:
// zoomkat 10-22-11 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// for IDE 0022 and later
// 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.writeMicroseconds(1500); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control
  Serial.println("servo-test-22-dual-input"); // 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

    // auto select appropriate value, copied from someone elses code.
    if(n >= 500)
    {
      Serial.print("writing Microseconds: ");
      Serial.println(n);
      myservo.writeMicroseconds(n);
    }
    else
    {   
      Serial.print("writing Angle: ");
      Serial.println(n);
      myservo.write(n);
    }

    readString=""; //empty for next input
  }
}

Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

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

hai zoomkat..
many thanks for your comment, is this sketch will recieve the serial data from java?
which part of this sketch accepting data from java??
Logged

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8911
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hai zoomkat..
many thanks for your comment, is this sketch will recieve the serial data from java?
which part of this sketch accepting data from java??

The code will receive data from most any application (java, VB, or whatever) that outputs the appropriate rs232 based serial communication.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

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

when i sending data to arduino from java, what kind of data type i have to send?
Logged

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8911
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

when i sending data to arduino from java, what kind of data type i have to send?

Ascii characters. Start testing by using the serial monitor. Java questions probably should be posted in a java forum for best answers.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Pages: [1]   Go Up
Jump to: