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 ?
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.
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 communicate. 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.
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?
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:
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".