We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all,
I'm beginner to processing and arduino. i intend to transfer a series data ( e.g. a series number) from processing to arduino. this numbers will turn a servo. i mean i want to send a series number from processing to arduino that these numbers control my servo position. I write two sketch, one of them for processing and another for arduino. but it seems processing does not sent any data to arduino or arduino unable to read data. i don't know what happens. please help. thanks a lot. Farrokh
=====================================
Processing sketch
import processing.serial.*;
Serial myPort;
int i;
void setup()
{
printArray(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
}
void draw ()
{
for (i=0; i < 150 ; i+=10){
myPort.write(i);
delay (100);
}
}
Arduino sketch:
#include <Servo.h>
Servo myservo;
void setup()
{
Serial.begin(9600);
myservo.attach(9);
myservo.write(5);
}
void loop()
{
while(!Serial.available());
myservo.write(Serial.read());
}
Answers
https://forum.Processing.org/two/discussion/8045/how-to-format-code-and-text
Use SerialEvent on the Arduino side. It triggers each time it receives serial data. Assign it to some variable there, and then use it to move servo.
You can try that without processing first, using serial monitor to send data to Arduino.