data transfering from processing to arduino

edited January 2016 in Arduino

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

Sign In or Register to comment.