Arduino with processing (which card ?)

Hello , I'm french and i need yours help.

I need to do a project with my school with arduino and processing. So first i use the arduino card "Uno" no problem. But i need to have more port for the sensors , so i have bought the "MegaADK" card but i can't communicate from processing to arduino.

SO i need to buy another card , and i need help on this. Can you help me to found an arduino card wich can connect with processing ?

Thx for your help.

Demondu36: i can't communicate from processing to arduino.

Why not? It ought to be possible, using the USB serial connection.

Don't use the host port on mega adk, use the client port. It should work like a mega 2560.

PeterH:
Why not? It ought to be possible, using the USB serial connection.

For exemple , I can’t control the led on the arduino card with a simple programme with processing.

PROCESSING:

//pour Processing:
import processing.serial.*;
Serial myPort; 
int val;
void setup() 
{
 size(200, 200);
 String portName = Serial.list()[2];
 myPort = new Serial(this, portName, 9600);
}void draw() {
 background(255);
 if (mouseOverRect() == true) { // Si la souris est sur le rectangle
 fill(250); // on change sa couleur
 myPort.write('H'); // et on envoie un H à l'arduino
 } 
 else { // Sinon, 
 fill(0); //
 myPort.write('O');
 }
 rect(50, 50, 100, 100); 
}boolean mouseOverRect() { // Teste si la souris est sur le rectangle
 return ((mouseX >= 50) && (mouseX <= 150) && (mouseY >= 50) && (mouseY <= 150));
}
ARDUINO

char val; //l'info reçue depuis Processing
int ledPin = 52; // la PIN de la LED...
void setup() {
 pinMode(ledPin, OUTPUT); // ... que l'on définit en OUTPUT
 Serial.begin(9600); // On lance la communication
}void loop() {
 if (Serial.available()) { // Si les données sont pr^tes à etre lues,
 val = Serial.read(); // on les stocke
 }
 if (val == 'H') { // Si c'est un 'H' qui est reçu
 //Serial.println(val);
 digitalWrite(ledPin, HIGH); // On allume la LED
 } 
 else {
 digitalWrite(ledPin, LOW); 
 }
 delay(5); // On attends la prochaine lecture
}

liudr:
Don’t use the host port on mega adk, use the client port. It should work like a mega 2560.

I already do that http://cjoint.com/14ma/DCAkVhnPLaP_sans_titre_1.bmp

Describe how the arduino behaves now, with mouse.

Demondu36: For exemple , I can't control the led on the arduino card with a simple programme with processing.

The question isn't whether you can control an LED, it's whether you can [u]communicate[/u]. I have no idea what that sketch and Processing application are supposed to do and you don't say what they actually do, but you don't need any of that complexity to show communication working. Just open a serial port and write to it on one side, and open the serial port and read from it on the other side. On receiving input, the receiver should do something tangible, such as display the input on the screen, or blink an LED.

liudr: Describe how the arduino behaves now, with mouse.

So , my program is only check for the communication with processing and arduino.

For do this I just do a program wich when i put the mouse in the case , processing send an information to arduino.

http://cjoint.com/14ma/DCBlz17bAY9_curseur_out_uno.bmp

And when i put the mouse in the case , processing send another information to arduino (H)

http://cjoint.com/14ma/DCBlBd2A2Ik_curseur_in.bmp

Result with Mega ADK: http://cjoint.com/14ma/DCBlGINmPs2_20140327_091348.jpg http://cjoint.com/14ma/DCBlIxbbHqY_20140327_091402.jpg

Oscilloscope Result : http://cjoint.com/14ma/DCBlOqKpMJI_20140327_110636.jpg Binaire result : 01001000 ASCII result : H

So the result with the IF on arduino is true.

Result with Arduino ethernet: http://cjoint.com/14ma/DCBlJ4e7whw_20140327_094603.jpg http://cjoint.com/14ma/DCBlLsmUxOb_20140327_094613.jpg

So i don't know why whan i change the card the program doesn't work ...

Can give an exemple for verify the connection with arduino and processing ?

THX

It seems that the LED on the mega board is blinking, is it not? The LED you soldered a resistor on is not blinking. You are using pin 52, but your LED is not connected to pin 52 so it shouldn't blink. With Arduino Ethernet, did you change pin to say 3?

Your MEGA board is MEGA 2560, not MEGA ADK.

liudr: It seems that the LED on the mega board is blinking, is it not? The LED you soldered a resistor on is not blinking. You are using pin 52, but your LED is not connected to pin 52 so it shouldn't blink. With Arduino Ethernet, did you change pin to say 3?

Sorry for the pin but it's my fault ^^' In the program the pin is 3 look the picture:

http://cjoint.com/14ma/DCBlz17bAY9_curseur_out_uno.bmp http://cjoint.com/14ma/DCBlGINmPs2_20140327_091348.jpg

liudr: Your MEGA board is MEGA 2560, not MEGA ADK.

Ah Oo. Thx for tell me this ..

And know i notice is not arduino the builder but SaintSmart : http://cjoint.com/14ma/DCBlIxbbHqY_20140327_091402.jpg

The problem come from here ??

I thinks I gonna buy an arduino card "Mage ADK for android".

No more help ? :~

In your pictures, your LED was blinking, so what issues do you still have? I'm willing to help. But point to your issue, like "This part should do X but it is doing Y or doing nothing".

It’s work with the ethernet ethernet card and not with the MEGA 2560.
And today i test it with the Uno card and it work too.

So I don’t understand why the program still doesn’t work with the 2560…

Are you using pin 52 on MEGA 2560? It's located on the far right with a bunch of other pins, not on the mail arduino header.

liudr: Are you using pin 52 on MEGA 2560? It's located on the far right with a bunch of other pins, not on the mail arduino header.

I do for the pin 52 and 3 ( i do a test for different pin).