We are about to switch to a new forum software. Until then we have removed the registration on this forum.
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int l = 0;
int r=-180;
int t;
float z;
void setup() {
frameRate(40);
size(500, 500);
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[0], 57600);
arduino.pinMode(10, Arduino.SERVO);
arduino.pinMode(8, Arduino.INPUT);
}
void draw() {
translate(250, 250);
background(250);
screen();
strokeWeight(3);
stroke(0, 255, 0);
strokeWeight(2);
if (l>=-181 ) {
l--;
t=1;
z = radians(l);
}
if (l<-180) {
r++;
t=r;
z = radians(r);
}
if (r==0) {
r=-180;
l=0;
}
pushMatrix();
rotate(z);
line(0, 0, 100, 0);
popMatrix();
}
void screen() {
stroke(0);
fill(0);
arc(0, 0, 200, 200, PI, TWO_PI);
}
void ar(){
arduino.servoWrite(10, t);
arduino.digitalWrite(8, Arduino.HIGH);
arduino.pulseIn(8, Arduino.HIGH);
}
pulseIn(int,int); is not a function, Can I add this to the arduino library or would it not work for processing even if added? Or is there another way to use a ping sensor in processing?
Answers
You'll get a better response if you format your code. Here's how:
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text
The arduino-library/firmat is great for simple things like reading/writing a pin.
But when you need more complicated code to adress your hardware/sensors, i would always write my own arduino-code. You can send still send messages between arduino and processing via Serial-connection.
Sorry about the code, I haven't used the new forum yet. Look better?
I was hoping to do all the coding in processing, so I was looking for a way to modify the cc.arduino library. I have only ever messed around with the motor library in arduino so I am not sure how to go about changing a processing one or even where to find it.
Thanks.