Pages: [1]   Go Down
Author Topic: Processing controlling arduino.  (Read 770 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know what I'm doing wrong. This is the first time I'm trying to control arduino outputs with processing and nothing is happening. x.x!

Processing Code:

Code:
import processing.serial.*;
import cc.arduino.*;
Arduino ard;
int led = 22;
boolean on = false;
void setup () {
  size(400, 300);       
  //println(Arduino.list());
  ard = new Arduino(this, Arduino.list()[2], 9600);  //My arduino is on COM5
  ard.pinMode(led, Arduino.OUTPUT);
  background(0);
}
 
void draw() {
  if(on) {
    fill(0,0,0);
  } else {
    fill(255,0,0);
  }
  rect(0,0,400,300);
}
void mouseClicked() {
  if(on) {
    on = false;
    ard.digitalWrite(led, Arduino.LOW);
  } else {
    on = true;
    ard.digitalWrite(led, Arduino.HIGH);
  }
}

Arduino Code:

Code:
void setup() {
  Serial.begin(9600);
}

void loop() {
}

Tks
Logged

Hannover, Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That's because nothing in the loop. The Arduino just repeats the empty loop and does nothing.
Logged

http://danimathblog.blogspot.com

#define true '/'/'/'
#define false '-'-'-'

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

But isn't processing supposed to set things on arduino?

What am I supposed to do? Didn't find any references about this. Only to processing.
Logged

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

Were you perhaps thinking of Firmata?
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.

Hannover, Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No. Processing isn't supposed to set things on arduino, but you can do it - as with C, Java, Perl, Python, ....

Link: http://www.arduino.cc/playground/Interfacing/Processing
Logged

http://danimathblog.blogspot.com

#define true '/'/'/'
#define false '-'-'-'

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

No. Processing isn't supposed to set things on arduino, but you can do it - as with C, Java, Perl, Python, ....

Link: http://www.arduino.cc/playground/Interfacing/Processing

I used that post to help me.
That example is in processing. Even if I copy it doesn't work.
That's why I'm not sure if I need to program something into the arduino too.
Logged

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

Yes, and did you read the bit about Firmata?
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.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31431
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
That's why I'm not sure if I need to program something into the arduino too.
Yes you do need something in the arduino.
You can use the code called Firmata, but it is not very flexible. Or better still write code in the arduino that does what exactly what you want.
Logged

Pages: [1]   Go Up
Jump to: