loading
The other day I was confronted with an interesting problem, I needed to control a series of lights from an interaction on a computer screen and it had to be as inexpensive as possible.  I instantly thought of an Arduino.  It had everything that I needed, more than enough I/O, an integrated USB and its only $30.  To communicate with the Arduino I decided to use Processing.  The two work really well together because of Arduino's close family relation to Processing.

Step 1: The Materials

Its time to gather all of the bits and pieces necessary to make this happen:

The Software:

Processing - can be found at www.processing.org
Arduino - Can be found at www.arduino.cc

The Hardware:
Arduino USB board (I used the Diecimila, because that's what I had)
8x LEDs of your choice
8x 330ohm resistors
Break away headers
single sided copper clad
Ferric Chloride
tiny drill bit
USB cable


Step 2: The Code

This was the hard part for me.  I have always been a hardware type rather than software type, so I turned to the internet.  the first place that I looked was the reference section of both Processing.org and Arduino.cc, a lot of time and consideration has gone into the development of these sites and I applaud the effort, it was worth it!  All the basic information that i needed was there but I was having a really hard time getting it all to work.  So i turned to this tutorial to set me straight.  Francesco has put together a great tutorial about Processing serial communication and the Arduino.

Once I got it all to work, it was actually very simple.  Basically the Processing code will be setup like this:

import processing.serial.*;

Serial myPort;

void setup(){ 
  println(Serial.list());
  myPort = new Serial(this, Serial.list()[*X*], 9600);
  myPort.buffer(1);
  size(400, 400);

void draw(){
 //some code goes here
}

When setting up your code make sure that your Arduino is connected to your serial port.  This is important because the code is attempting to point to the specific arduino that you are using.  Run your code and look at the list that will be displayed at the bottom of your Processing window and then change the variable in your code that i have indicated by the *X* to the number of the port that your arduino is connected to.  Mine was the third on the list so I put 2 in place of the *X*.  Keep in mind that the list is displayed as array entries, this means that the first position is indicated as 0 not 1.

The Arduino code is even simpler to setup:

void setup(){
 Serial.begin(9600);
}

I have posted the completed codes for you to take and modify and play with.  The arduino is saved as pdxMap.pde and the processing code is saved as serialLEDTest.pde



Step 3: Make the Circuit Board

I created the circuit board using CADsoft Eagle.  Since I knew that I was using an arduino I wanted to make a protoshield that would fit the odd spacing on the USB boards, So back to the internet to find the right Eagle part.  I ended up using the Protoshield layout that was designed by Lady Ada.  If you are not familiar with her work you should check her out.   Her projects and contributions to the world of physical computing are outstanding and most of her work is open source giving people like me a chance to take their own projects to the next level.

After I found the protoshield layout, I opened it and modified it in Eagle to what you see below.  The second image is a close up of the PDF that will create the final board.  There are a lot of great instructables about etching your own circuit board so i will not go over all the details here.  The method that I like to use is describe beautifully in TechShopJim's instructable.

Step one: Print the PDF (found below) onto magazine paper, high gloss photo paper or a paper that is designed for PCB.  Print using a laser printer.  do not scale, it is layed out on a 8 1/2 by 11 piece of paper and it should print just fine with out modification
Step two: Cut out the design leaving a little bit of a boarder around the design.
Step three: Cut a piece of your copper clad that is a little bit larger then the design.  the board can be cut by a bandsaw, a hack saw.  But usually I will use a box cutter or Xacto knife by scoring it over and over again and then breaking it along the score line and cleaning up the edge with sand paper.
Step Four: clean the copper clad with an SOS scrub pad or steel wool until it shines, rinse it off and make sure not to touch the surface with your hands.  Any grease on it will make it so the toner will not stick to the copper.
Step five: place the copper clad board onto a flat surface with the copper facing up, lay the cutout design toner side down onto the copper and tape it in place, put a paper towel over the whole thing and iron it on the the highest setting on your iron.  NO STEAM!  Place the iron directly on top, let the board heat up a bit before you move the iron and then take the edge of the iron and burnish the entire thing to make the toner stick to the copper.  it should take about 3 min total. Remove iron and paper towel.
Step six: Soak the board in water to get the paper off.  Don't be to rough while trying to take off the paper, the toner is very fragile and can easily scrape off.  (If, for what ever reason it doesn't work, just take the SOS pad or steel wool to the board again and clean off any residual toner.)
Step six: Etch!


**UPDATE**

You can grab the PDF here.  If you interested in the Eagle files, her is the .brd file and the .sch file

Step 4: Drill the Holes and Populate the Board

Now that you have a circuit board it's time to drill the holes with your tiny drill bit and solder on the components.

You will notice that I have created the board with the trace on the top side instead of the bottom of the board.  I did that because it makes it easier to solder the headers onto the board and have it sit flat against the arduino.

I started with the resistors when populating the board.  Bend the leads as close to the resistor as possible and put them into the board and solder and clip the excess leads.  You can next install the headers or the LED's.  The LED's have to be mounted proud of the board in order to solder them in place so I would suggest doing them last but since the component count is so low it doesn't really matter which parts are installed first. 

Step 5: Load Your Sketch

Load the pdxMap.pde sketch onto your arduino and plug the protoshield into the board.  Make sure that you plug your arduino into the same serial port that you have changed your processing sketch to reflect.

Next open the processing sketch and click the play button.  A window will pop up with your program running in it.  By clicking in each of the red rectangles it will light up the corresponding LED on the arduino for about one second





Please feel free to post any questions or comments and post your modifications and projects, I would love to see them!

<p>how to make arduino as the input and processing is the output,,e.g. when the led is turned off the processing will light up</p>
<p>i am getting this error in processing<br>size() cannot be used here <br>please help me ASAP!!!<br>thanks in advance</p>
<p>I test you sketch and proplem, list board have com8 but then come error</p><p>Arrayindexoutof bounds exception: 8</p><p>?????? what mean ? what must doing ?</p><p>why com8 not responce ? i adding number 8 place 2=X</p>
Hello, I am trying to use this code to control my Arduino Uno (just 8 pins, like this situation) but every time I try to upload the code i get the error: <br> <br>'import' does not name a type <br> <br>Do any of you know how to fix this or what I am doing wrong? <br> <br>Thank you.
&nbsp;I want to control the leds from internet...<br /> <br /> can you do that?<br /> <br /> :S please&nbsp;<br />
Yes, but you would need a ethernet of wifly shield.
Hi Sammy, I understand your coding :) I try to cut off your code pdxMap.pde like this: <br> <br>void loop() <br>{ <br>int input = Serial.read(); // read serial <br>if (input) { // detect input from serial <br>digitalWrite(Pin[input], HIGH); <br>delay(1000); <br>digitalWrite(Pin[input], LOW); <br>} <br> <br>Nice work!! Thanks to share.
Thanks for this and i have a question on that :<br>can i controller in RC car using this method of controlling ?
Thanks, this was really helpful. I set it up on a breadboard rather than making a custom pcb and it worked great. My first successful us of Processing.
Thanks - worked for me :)<br><br>p.s. LEDs is the plural of LED - so no apostrophe
Neat project. I downloaded the pdf file and when I printed it some of the traces are touching. Is there any chance you could post your Eagle files so that I could clean it up a little bit?<br />
Thanks, I&nbsp;posted the Eagle schematic and board file along with the PDF.&nbsp; Hopefully that helps!<br />
Hey man thanks for the effort, but for some reason neither the board or schematic files is working. If it's not to much trouble could you have a look at that. Thanks again!<br />
Sorry about that, it should be working now.&nbsp; good luck!<br />
Sorry, it must be on my end. Every time I download it it is saving it as a .tmp file. I see what you are doing so I will just recreate it in Eagle.<br /> <br /> Thanks<br /> Jman<br />
Try changing the name of the file to &quot;LED ProtoShield.brd&quot; and &quot;LED ProtoShield.sch&quot; when you are saving it.<br />
This worked perfectly for me! I was able to get the right serial input by following your instructions and it worked great. I am just starting to learn about programmable IC's and this was a good easy learning curve.<br /> <br /> I did have to make my own Eagle file as I was never able to upload your, and your PDF was coming out with traces touching for me. I am going to try to upload my PDF in case anyone had the same problem as me. Mine is made with the copper side down though.<br /> <br /> http://www.italentshare.com/storage/PICs/LEDShield.pdf<br />
Nifty gizmo!<br /> <br /> I&nbsp;always think that using 8 pins to control 8 leds is overkill...but so is using a shift register to use 3 pins instead of 8 :D<br /> <br /> Great little learning chunk!<br />

About This Instructable

116,677views

57favorites

License:

More by SammyDestruction:How to control LED's with Processing and Arduino 
Add instructable to: