Planète Électronique Vintage
Bienvenue sur Planète Électro Vintage, le forum des passionnés d'électronique analogique et numérique.

Welcome to Planète Électro Vintage, the forum of analog and digital electronics enthusiasts.


Rejoignez le forum, c’est rapide et facile

Planète Électronique Vintage
Bienvenue sur Planète Électro Vintage, le forum des passionnés d'électronique analogique et numérique.

Welcome to Planète Électro Vintage, the forum of analog and digital electronics enthusiasts.
Planète Électronique Vintage
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Derniers sujets
» Laquelle ?
Processing EmptyHier à 9:15 par Janpolanton

» Projet de VU-mètre stéréo à tubes cathodiques 902 A
Processing EmptyHier à 8:26 par defjones

» Perplexe sur puissance HF des CB "modernes"
Processing EmptyMer 8 Mai - 23:32 par Roger33

» Les supports
Processing EmptyLun 6 Mai - 12:41 par Roger33

» Logo Cabasse
Processing EmptyDim 5 Mai - 16:15 par defjones

» Les mystères de l'informatique
Processing EmptyVen 3 Mai - 9:20 par Janpolanton

» schéma du syster hack 3
Processing EmptyLun 29 Avr - 19:30 par Mannix54

» Mini chaine Problème double K7 et Lecteur CD
Processing EmptyVen 26 Avr - 18:46 par Bruno_Picard

Le deal à ne pas rater :
Cartes Pokémon 151 : où trouver le coffret Collection Alakazam-ex ?
Voir le deal

Processing

Aller en bas

  • 1

Processing Empty Processing

Message par Janpolanton Sam 11 Fév - 13:44

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
Janpolanton
Janpolanton
Admin
Admin

Messages : 2980
Date d'inscription : 20/12/2021
Age : 70
Localisation : Meaux 77

https://planetelectrovintage.forumactif.com

Revenir en haut Aller en bas

  • 2

Processing Empty Re: Processing

Message par Janpolanton Sam 11 Fév - 14:25

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:


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.
Janpolanton
Janpolanton
Admin
Admin

Messages : 2980
Date d'inscription : 20/12/2021
Age : 70
Localisation : Meaux 77

https://planetelectrovintage.forumactif.com

Revenir en haut Aller en bas

Revenir en haut

- Sujets similaires

 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum