Arduino to processing

edited April 2014 in Arduino

Hello guys i'm french boy. Sorry for ma English :) I have a project, display arduino data to processing. For this i have the card of Arduino(Mega 2560), i get data in arduino, but i can't display to arduino :(. That's is my program Arduino

char Vitesse; char Autonomie; char Utilisateur;

void setup() { Serial.begin(9600); //set baud rate on Arduino to 9600 }

void loop() { // Pour la Vitesse...... if (Serial.available() > 0) { Vitesse = Serial.read(); Serial.write(Vitesse);

}

 // Pour l'Autonomie.......

if (Serial.available()> 0) { Autonomie = Serial.read(); Serial.write(Autonomie); }

// Pour l'Utilisateurs.......... if (Serial.available()>0) { Utilisateur = Serial.read(); Serial.write(Utilisateur); } }

and this is my program Processing

import processing.serial.*;

// Attention: Changez ce numéro pour le bon port au besoin int numero_du_port = 0; // ...ou 1, 2, 3...

Serial mon_port; String vitesse = "";
String autonomie = "";
String utilisateur = "";

void setup() { size(500, 550); println("Liste des ports: \n" + Serial.list()); String nom_du_port = Serial.list()[numero_du_port]; mon_port = new Serial(this, nom_du_port, 9600); background(93, 143, 94); }

void draw() {

if (mon_port.available() != 0) { // Conversion du int en char vitesse = str(mon_port.read()); autonomie = str(mon_port.read()); utilisateur = str(mon_port.read()); }

text("Vitesse du Gyropode: " + vitesse, 10, 50); text("Batterie du Gyropode: " + autonomie, 10, 70); text("Utilisateur du Gyropode: " + utilisateur, 10, 90); } Ps: Sorry for my english. Please i need help

Tagged:

Answers

  • In the Processing menu you can select example code to run. One of the examples for serial is called SerialDuplex. Try that code because it will allow you to transmit a keyboard character out the serial port and then display a character received by the serial port.

  • Thank you for your help :) i test it !

Sign In or Register to comment.