Derniers sujets
Processing
Page 1 sur 1
Processing
Bonjour à tous,
Aujourd'hui je vous présente Processing que certains connaissent peut-être déjà.
Je m'en suis servi il y a quelques années et je l'avais un peu oublié.
Il faut dire que depuis, il a vraiment évolué.
Les circonstances de son utilisation:
J'avais fait un traceur de caractéristiques de transistors très succinct avec un Arduino et quelques composants pour envoyer le contenu du port série d'un Arduino vers un tableau LibreOffice Calc en utilisant Processing ainsi que quelques lignes de code en Python. (un peu comme le data logger de @jmespe )
Si je retrouve le dossier je le publierai mais depuis, j'ai changé 2 fois de PC alors, rien n'est moins sûr.
Ci-dessous, le lien vers Processing et quelques exemples. Bonne lecture.
Le lien vers Processing
Arduino et Processing
Python et LibreOffice
Aujourd'hui je vous présente Processing que certains connaissent peut-être déjà.
Je m'en suis servi il y a quelques années et je l'avais un peu oublié.
Il faut dire que depuis, il a vraiment évolué.
Les circonstances de son utilisation:
J'avais fait un traceur de caractéristiques de transistors très succinct avec un Arduino et quelques composants pour envoyer le contenu du port série d'un Arduino vers un tableau LibreOffice Calc en utilisant Processing ainsi que quelques lignes de code en Python. (un peu comme le data logger de @jmespe )
Si je retrouve le dossier je le publierai mais depuis, j'ai changé 2 fois de PC alors, rien n'est moins sûr.
Ci-dessous, le lien vers Processing et quelques exemples. Bonne lecture.
Le lien vers Processing
Arduino et Processing
Python et LibreOffice
Re: Processing
Et avec l'aide de ChatGPT qui connait "Processing" :
Janpol Anton :
how to receive arduino serail monitor datas with processing?
To receive data from the Arduino Serial Monitor in Processing, you can use the Serial library. Here's an example of how you can receive the data and display it in Processing:
In this example, the Serial.list() method is used to retrieve a list of available serial ports, and the first port in the list is selected. The baud rate is set to 9600, which should match the baud rate you set in the Arduino sketch. The myPort.bufferUntil('\n') method sets the buffer size to wait until a newline character is received before processing the data.
The serialEvent function is automatically called whenever data is received by the serial port, and the received data is stored in the val variable. The draw function is used to display the received data on the screen.
Remember to match the baud rate in both the Arduino sketch and the Processing code.
Janpol Anton :
how to plot arduino's data in processing. Give me an example
Here's an example of how you can plot data from the Arduino in Processing:
In this example, the Serial library is used to receive data from the Arduino in the same way as in the previous example. However, this time the received data is assumed to be two floating-point values separated by a comma, and the split function is used to separate the values into the x and y variables.
The draw function is used to display an ellipse at the x and y coordinates. The coordinates are mapped to the screen size, so you may need to adjust the values to fit within the screen dimensions.
Remember to match the baud rate in both the Arduino sketch and the Processing code, and make sure the data sent from the Arduino is in the correct format for Processing to parse it correctly.
Janpol Anton :
how to receive arduino serail monitor datas with processing?
To receive data from the Arduino Serial Monitor in Processing, you can use the Serial library. Here's an example of how you can receive the data and display it in Processing:
- Code:
import processing.serial.*;
Serial myPort; // Create object from Serial class
String val; // Data received from the serial port
void setup() {
size(200, 200);
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil('\n');
}
void draw() {
background(200);
fill(0);
text(val, width/2, height/2);
}
void serialEvent(Serial myPort) {
val = myPort.readStringUntil('\n');
}
In this example, the Serial.list() method is used to retrieve a list of available serial ports, and the first port in the list is selected. The baud rate is set to 9600, which should match the baud rate you set in the Arduino sketch. The myPort.bufferUntil('\n') method sets the buffer size to wait until a newline character is received before processing the data.
The serialEvent function is automatically called whenever data is received by the serial port, and the received data is stored in the val variable. The draw function is used to display the received data on the screen.
Remember to match the baud rate in both the Arduino sketch and the Processing code.
Janpol Anton :
how to plot arduino's data in processing. Give me an example
Here's an example of how you can plot data from the Arduino in Processing:
- Code:
import processing.serial.*;
Serial myPort; // Create object from Serial class
float x; // Data received from the serial port
float y;
void setup() {
size(400, 400);
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil('\n');
}
void draw() {
background(255);
stroke(0);
fill(175);
ellipse(x, y, 16, 16);
}
void serialEvent(Serial myPort) {
String data = myPort.readStringUntil('\n');
if (data != null) {
data = trim(data);
String[] values = split(data, ',');
x = float(values[0]);
y = float(values[1]);
}
}
In this example, the Serial library is used to receive data from the Arduino in the same way as in the previous example. However, this time the received data is assumed to be two floating-point values separated by a comma, and the split function is used to separate the values into the x and y variables.
The draw function is used to display an ellipse at the x and y coordinates. The coordinates are mapped to the screen size, so you may need to adjust the values to fit within the screen dimensions.
Remember to match the baud rate in both the Arduino sketch and the Processing code, and make sure the data sent from the Arduino is in the correct format for Processing to parse it correctly.
Page 1 sur 1
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum
|
|
Hier à 9:15 par Janpolanton
» Projet de VU-mètre stéréo à tubes cathodiques 902 A
Hier à 8:26 par defjones
» Perplexe sur puissance HF des CB "modernes"
Mer 8 Mai - 23:32 par Roger33
» Les supports
Lun 6 Mai - 12:41 par Roger33
» Logo Cabasse
Dim 5 Mai - 16:15 par defjones
» Les mystères de l'informatique
Ven 3 Mai - 9:20 par Janpolanton
» schéma du syster hack 3
Lun 29 Avr - 19:30 par Mannix54
» Mini chaine Problème double K7 et Lecteur CD
Ven 26 Avr - 18:46 par Bruno_Picard