I’m a newbie to programming on the Arduino, and even greener on Processing language (just learned about the program a few days ago). Anyway, I was perplexed that I couldn’t get Arduino and Processing to talk to each other over the serial port. Went to forums, websites, etc... (nothing worked)! But your excellent tutorial was the answer!! I was able to reproduce what you did, then carry the critical portions of the code you demonstrated, to my program (PhysicalPixel), that I was working on... and Eureka!! Thanks so much!!!!
I have just been using processing for a few hours but now I can read serial data and visualise acc and other data from the micro:bit in real time. I´m using the radio feature on the micro:bit, really simple and you can read off any other microbit with radio send feature enabled. Great help thanks for sharing!
what if I have more than one variable, e.g. variable2, variable3, how do you separate them into individual variables at the processing end so you can have 3 bars being drawn simultaneously.
Print them in the arduino code separeted by a coma or something an then create a String array that separates the values divided by comas using the split() function: String[] example = split ( val, ',' ); Here the "val" is the string imported from the arduino and ',' is the character that divides the string. Then if your arduino is sending for example: 12,230,123 example[0] is going to be 12, example[1] is going to be 230 and example[2] is going to be 123.
When communicating with Arduino from Processing, can I use the same conversion method wich was used in the video in Processing (myVal = float(myString); ) from string to int or float for numbers between 0 and 100?
send something like this Serial.println(sensor1); Serial.println('a'); Serial.println(sensor2); Serial.println('b'); And instead of using the 10 ascci character use alphabet letters as flags.
@@zchi.-4736 It was 8 months ago so I don’t remember too well. I think the problem had something to do with using the serial port 2 different ways at once
Hi, I'm using an Arduino Mega 2560 and almost everything works fine, it doesn't show me any error, but the value of my variable in processing it doesn't change, and on my Arduino it appears no data on the window that open once you click on the "zoom" icon. I'm totally a newbie on Arduino but I understand Processing
C Liviu the serial port (on the com that your arduino board is) is singular. So on a 'first come first served' basis only one application can view that data at a time. Multiple programs can place data into it. But only one can see/use the data at a time!
MySting is in what format? Say the random chooser from arduino chooses int 10 and prints it in the serial port, what goes on in processing, what does it convert ingo a float?
It’s normally transferred in ascii, so when it reaches processing it’s a number. You need to read it as one and transfer it into a string again (normally)
This is super close to doing something I need to do for a project im so excited to find it, but... there's a few things im not clear on (I am a total noob) . 1: where is this "processing" window coming from? Is it part of the arduino ide or what? 2. Can someone walk me thru the "this" and "new" commands talked about at 5 min? I can't find any reference material. Please help! Thx!
1. it is not a part of the arduino yet it has a connection. 2. the language used on the processing app is java. im still new to java so here is a link: th-cam.com/video/NTXkmpfTklQ/w-d-xo.html you can watch to teach you java.
just so people dont fall into this . i fell into processing accidentally cause there is no school around me. the processing language is alot like rebol language and there is very little done in it as far as computers are concerned. after u use it on simple things like blinking arduino leds it becomes very very very hard to get information on. i spent 1 year 30 minutes a day to transfer and array to a file. (A YEAR 30 MINUTES A DAY). DONT DO IT. ITS LIKE DEVIL WORSHIP .
Then you are either doing it wrong or not using it in the ways in which it excels. Processing is simply java and dont you dare try to say their is a lack of documentation on java. further, Processing the environment offers plenty of support and tutorials on their website. Further there are fantastic TH-cam channels (The Coding Train) that have dedicated literally hundreds of hours to tutorials on the subject. FURTHER Processing the environment can be used to code other languages such as but not limited to JavaScript. Which brings me to my last point, Java is not the end all, and is antiquated by the language JavaScript. JavaScript allows you to access and work within a browser, so if you want to do more than a program on your computer (not limited to blinking lights) than learn something else! Maybe than you may surpass your Array issues!
import processing.serial.*; //includes the serial object libreary Serial mySerial; //creates local serial object from library String myString = null; //a variable to collect serial datra int nl = 10; //ASCII code for carage return in serial float myVal;//float for storing converted ascii serial data void setup(){ size(200,400);
//link proicessing to serial port (corect one) String myPort = Serial.list()[1]; //find correct serial port mySerial = new Serial(this, myPort, 9600); }//setup
void draw(){
while (mySerial.available() > 0){ myString = mySerial.readStringUntil(nl); //STRIPs data iof the serial port
if (myString != null){ background(0); myVal = float (myString); //takes data from serial and turns it into number
myVal = myVal/100 *height;
rectMode(CENTER); rect(width/2, height-(myVal/2), 100, myVal); }//data was in the serial port }// do something if there is data on the port }//drwa
So simple but it opens up a whole range of possibilities - thanks
Perhaps I don't have enough experience with processing, but what exactly does this let me do?
I’m a newbie to programming on the Arduino, and even greener on Processing language (just learned about the program a few days ago). Anyway, I was perplexed that I couldn’t get Arduino and Processing to talk to each other over the serial port. Went to forums, websites, etc... (nothing worked)! But your excellent tutorial was the answer!! I was able to reproduce what you did, then carry the critical portions of the code you demonstrated, to my program (PhysicalPixel), that I was working on... and Eureka!! Thanks so much!!!!
Man u have no ideia how much this helped my, i was losing my mind on this. Thanks a lot!!
This is such a useful tutorial, thank you so much.
Very helpful video. May I suggest making your font larger on future videos. Barely readable on my iPad. Thanks for the great info.
I have just been using processing for a few hours but now I can read serial data and visualise acc and other data from the micro:bit in real time. I´m using the radio feature on the micro:bit, really simple and you can read off any other microbit with radio send feature enabled. Great help thanks for sharing!
what if I have more than one variable, e.g. variable2, variable3, how do you separate them into individual variables at the processing end so you can have 3 bars being drawn simultaneously.
Print them in the arduino code separeted by a coma or something an then create a String array that separates the values divided by comas using the split() function:
String[] example = split ( val, ',' );
Here the "val" is the string imported from the arduino and ',' is the character that divides the string. Then if your arduino is sending for example: 12,230,123 example[0] is going to be 12, example[1] is going to be 230 and example[2] is going to be 123.
Really appreciated the explanation!! Cheers
While trying to do serial communication it is showing could not load jssc library. (I am using MacOS). any solution ?
If I want to send and receive data between Arduino and unity.
Should I use the same kinda code on both side? In the Arduino and in unity.
When communicating with Arduino from Processing, can I use the same conversion method wich was used in the video in Processing (myVal = float(myString); ) from string to int or float for numbers between 0 and 100?
good work thank u
what about sending data of 2 or more variables (sensors data) ?
send something like this
Serial.println(sensor1);
Serial.println('a');
Serial.println(sensor2);
Serial.println('b');
And instead of using the 10 ascci character use alphabet letters as flags.
Why don't you full screen the IDE so we can see what you do?
I tried sending data from my pc to the board and I get the error “error opening serial port com4: port busy”
Same with you, how did you solve this problem? I used the Mac OS, and I want to use the button on the Arduino to control the UI coded by processing,
@@zchi.-4736 It was 8 months ago so I don’t remember too well. I think the problem had something to do with using the serial port 2 different ways at once
how to send multiple pieces of data through the serial port to processing? Help
Thanks for a great tutorial!
Thank you for this tutorial!
how numeric value can be send to arduino from processing sketch
ArrayIndexOutOfBoundsException
I get this every time , my arduino is connected to COM5 and I put [4]
me to
@@jonasverboven1728 Ive got it working, use processing version 2.2.1
@@jonasverboven1728 and use serial print command not serial write
@@jonasverboven1728 if it still doesnt work, tell me the problem ill try to help you
@@filiphodak6792 iw il try it thx
and i will let you know if it works
That was really helpful.Thanks dude.
Hi, I'm using an Arduino Mega 2560 and almost everything works fine, it doesn't show me any error, but the value of my variable in processing it doesn't change, and on my Arduino it appears no data on the window that open once you click on the "zoom" icon. I'm totally a newbie on Arduino but I understand Processing
gracias genio.. me tenía loco este tema. una explicación perfecta
Saludos
Gabriel
My arduino port in linx is /dev/tty/USB0 how do I get that to work? thanks
GREAT VIDEO MY FRIEND YOU HELP ME A LOT
Why can't you open serial monitor is processing sketch is running?
C Liviu the serial port (on the com that your arduino board is) is singular. So on a 'first come first served' basis only one application can view that data at a time. Multiple programs can place data into it. But only one can see/use the data at a time!
C Liviu mostly to do with the age of serial ports. The are like the OG of data transfers, before we got parallel processing etc!
@@Programmingforpeople parallel processing you say?
MySting is in what format? Say the random chooser from arduino chooses int 10 and prints it in the serial port, what goes on in processing, what does it convert ingo a float?
It’s normally transferred in ascii, so when it reaches processing it’s a number. You need to read it as one and transfer it into a string again (normally)
This is super close to doing something I need to do for a project im so excited to find it, but... there's a few things im not clear on (I am a total noob) . 1: where is this "processing" window coming from? Is it part of the arduino ide or what?
2. Can someone walk me thru the "this" and "new" commands talked about at 5 min? I can't find any reference material.
Please help! Thx!
1. it is not a part of the arduino yet it has a connection.
2. the language used on the processing app is java. im still new to java so here is a link: th-cam.com/video/NTXkmpfTklQ/w-d-xo.html you can watch to teach you java.
that float(myport) instruction is what im after i think. thanks for posting
This is great, thank you so much!
I don't get it
ascii 10 is carriagee return
Nice thanks thats helped me a lot
Thx 4 Ur effort mate. quite helpful,,;)
plz up your font size!!!!!!!!!!!!!
Haha yes - the quality of our production has changed a lot since this video was made!
@@Programmingforpeople ok graet
just so people dont fall into this . i fell into processing accidentally cause there is no school around me. the processing language is alot like rebol language and there is very little done in it as far as computers are concerned. after u use it on simple things like blinking arduino leds it becomes very very very hard to get information on. i spent 1 year 30 minutes a day to transfer and array to a file. (A YEAR 30 MINUTES A DAY). DONT DO IT. ITS LIKE DEVIL WORSHIP .
what do you recomend then?
Then you are either doing it wrong or not using it in the ways in which it excels. Processing is simply java and dont you dare try to say their is a lack of documentation on java. further, Processing the environment offers plenty of support and tutorials on their website. Further there are fantastic TH-cam channels (The Coding Train) that have dedicated literally hundreds of hours to tutorials on the subject. FURTHER Processing the environment can be used to code other languages such as but not limited to JavaScript. Which brings me to my last point, Java is not the end all, and is antiquated by the language JavaScript. JavaScript allows you to access and work within a browser, so if you want to do more than a program on your computer (not limited to blinking lights) than learn something else! Maybe than you may surpass your Array issues!
nice tutorial but full of holes and shortcut in your explanation, good anyway thanks
U are best
import processing.serial.*;
Serial mySerial;
String myString = null;
int nl = 1-;
float myVal;
void setup()
{
size(200,400);
String myPort = Serial.list() [1];
mySerial = new Serial(this, myPort, 9600);
}
void draw()
{
while(mySerial.available()>0)
{
myString = mySerial.readStringUntil(nl);
if(myString != null)
{
background(0);
myVal = float(mystring);
myVal = myVal/100 *height;
rectMode(CENTER);
rect(width/4, height - (myVal/2), 100, myVal);
}
}
}
import processing.serial.*; //includes the serial object libreary
Serial mySerial; //creates local serial object from library
String myString = null; //a variable to collect serial datra
int nl = 10; //ASCII code for carage return in serial
float myVal;//float for storing converted ascii serial data
void setup(){
size(200,400);
//link proicessing to serial port (corect one)
String myPort = Serial.list()[1]; //find correct serial port
mySerial = new Serial(this, myPort, 9600);
}//setup
void draw(){
while (mySerial.available() > 0){
myString = mySerial.readStringUntil(nl); //STRIPs data iof the serial port
if (myString != null){
background(0);
myVal = float (myString); //takes data from serial and turns it into number
myVal = myVal/100 *height;
rectMode(CENTER);
rect(width/2, height-(myVal/2), 100, myVal);
}//data was in the serial port
}// do something if there is data on the port
}//drwa
Stupid example! Blocks MCU when serial received bad character.
no te entendí ni verga no se inglés.