Arduino USB Communication - Processing Program

19K3212

Intro: Arduino USB Communication - Processing Program

Since I had some problems looking for information about how to communicate the Arduino's board with the computer program, I decided to do this tutorial.

This tutorial will show you how to do a simple program (with a friendly interface - that anyone can work with), that can communicate with Arduino.

So, if you are tired of opening your "SERIAL MONITOR" in the Arduino's IDE and type all the commands, you might want to do something like this. 

At first, I was trying to make a simple program in which I could control the lights in my garden. Later on, I used this very same program to test all of my Arduino applications.



Some observations before we start:
            -- I'm not teaching how to use Arduino or Prossesing, this is just a explanation of it's capabilities.
            -- I've tried to do what I did with other languages like C, C++, delphi, etc... And turns out that the simplest way of doing what I did is using Processing. If you never used it, give it a shot... You will be surprised.
            -- Keep in mind that this is just an example program, after you get familiar with the program you can do your own stuff in order to attend your needs... Or you can just use the example program, whatever.
           -- I've used some hulk images in the program. I think Hulk is cool so I used it just for you to see how to add images in your programs. I did not do it by myself, I've got the hulk images in the internet.


Materials List
--Arduino UNO
--Two or three LED's (I used three)
--Two or three Resistors (250 ohms or similar will do the work)
--Arduino USB cable


Programs list
--Arduino's IDE  (you can download it for free in Arduino's web page)
--Processing IDE (you can download it for free in Processing's web page)
--Ms button maker ( http://www.softpedia.com/get/Internet/WEB-Design/Web-Design-related/Ms-Button-Maker.shtml)


**For futher informations about how to deal with Arduino, visit http://arduino.cc/en/

**For futher informations about how to deal with Processing, visit: http://processing.org/

You will find several tutorials, and learning stuff. You can easily learn how to work with Arduino and Processing.



Comments
I'm not giving you a huge and detailed explanation here, because I tried to do a very well commented program, you can just go to the program and everything will be there, explained (I hope).

As it is an example program, I did a general HMI (human machine interface) but you can improve it for your proposes. 

The very first thing you should know about this example is that I used the USB Port --> COM4. If you want to change it, you shall go to line 182 in the Processing program and change it.

I also used three LED attached to the pins 13, 12, 11 and an variable resistor attached to pin 0 (it is not shown in the images because I took it off. Actually you do not need it to test your program -- without it you will have a "float point" in your input and the value of the input will be oscillating).

I did not attached any diagram or draw in order to show the connections, because it is simple. If you have any problems, you can go to http://arduino.cc/en/Tutorial/HomePage, and check how to use a LED or how to use a variable resistor.

If you want to change the title of the application, go to line 504 in the Processing file, and change it by yourself. 

You need to have a folder call data in the same place as your Processing file, to keep you images and stuff.
You can also go to   --> Sketch --> add file  in the Processing IDE, and it will automatically make this folder to you.

I used the "Ms button Maker" (link above) to do the button, but you can use whatever you want, even paint.

So, get the Zip file, and study the programs, if you have an minimum of experience on Arduino, I'm sure you will get it And soon you will be able to make some progress on your own.

12 Comments

Hi!

The compressed file (Project1.zip) doesn't work: please, may you fix it? Thank you!

Bye!

Hey alfredone78.

Thanks for your commen!! I have checked and could not find the problem.

I have uploaded a copy to dropbox so you can download it from there:

https://www.dropbox.com/s/jtdsid3fmuugz1c/Project1.zip?dl=0

I'll update the tutorial to make this link more "accessible" to everyone.

Let me know if you have any problem downloading or using the program.

Thank you!!! The file on dropbox works!!!

The original file is downloadable but when I go to unzip, then it doesn't work!

Hello Luiz. I think don't understand what you need?

To download the zip file, click your mouse over the link.

Could you try to explain better? I'll be happy to help!

Hey Man. I'm glad that you liked. Thanks.

Really appreciate the effort here but I'm not sure you can leave so much "open material" here and hope the community can "fill in the blanks". I understand it's an "example program" but for beginners it makes it kind of difficult to "fill in the blanks".

"**you'll notice that some parts of the program are "missing", do not forget that this is an example program."

Hmmm....makes it difficult to even use this. Shouldn't there also be a stand alone file from the Processing software?

Again, really appreciate the work here and I couldn't have done it. But that is why I came here. Thank you.

Hello Soccernut43,

Thank you for your comment.

I liked your tips and I'll work to try to make it more accessible to people.

Let me know if you have any other suggestion, also let me know if you need help with the program. I'll be glad to help.

Thanks for your quick reply. For me unfortunately, I'd need a complete start to finish to compare to and work through. The whole instruction was exactly what I was looking for. But when it was kind of incomplete I didn't have the expertise to finish it. If it was complete it would be great.

Thanks for all your hard work.

Can I add this source code to my site too... Thanks

Hi mbojanic, feel free to add the code to your site =]