3

I have problem to send data from processing to arduino mega.

Processing Code :

import processing.serial.*;
Serial myPort;
void setup()
{
println(Serial.list());
String arduinoPort = Serial.list()[0];
myPort = new Serial(this, arduinoPort, 9600)
}
void draw()
{
byte a= 3;
myPort.write(char(a));
}

Arduino Code :

#include <Servo.h>
#include <Wire.h>
Servo myservo1;
Servo myservo2;
void setup()
{ 
Serial.begin(9600);
myservo1.attach(9); 
myservo2.attach(10);
myservo1.write(90);
myservo2.write(90);
}
void loop()
{
if(Serial.available()>0){
myservo1.write(70);
myservo2.write(70);
}
}

Code is really simple, processing send a value to trigger arduino mega turning 2 servo motors.

But it doesn't response at all.. Please help if anyone has any clue.

Thanks :))

asked Jan 21, 2015 at 19:11
2
  • 2
    Some things to try: 1) Send the output from Processing to a terminal to check that Processing does what you think it should do. 2) Send the "correct" text to the Arduino from a terminal to check whether correct text will cause the proper response. 3) Put one or more LEDs on your board and light them when significant things happen such as receiving any text, attempting to control the motors, etc. 4) Keep on testing smaller and smaller parts of the system until you identify something that behaves differently than you intended it to. Fix that and try again. Commented Jan 21, 2015 at 22:05
  • Thanks a lot Robert! Finally I realized its because I didnt add delay after every time sending data to arduino.. Commented Jan 25, 2015 at 13:53

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.