PC to Arduino to LED Control

As I’ve mentioned in previous posts (like the slideshow here), I want to build a teleoperated mining robot. Since I’m somewhat short of both cash and experience, I have to start small.

One key part of the system will be to create an interface to control the robot via computer. And to do that, I have to first be able to control anything, anything at all, by computer.

Hence, the following project.

First I wrote a program — or ‘sketch’ as it is called — in the Processing computer language. Here’s what the sketch window looks like on the computer screen:

You take your mouse cursor and click on a square. The color of the square goes from dim to bright. At the same time, an LED of the same color lights up. Click the square again, and it goes dim and the LED goes off.

The whole circuit looks a little like this:

The laptop runs a Processing sketch, which produces the screen image of colored squares, which the user then clicks with the mouse. The Processing sketch reads the clicks and converts them into one byte commands which are then sent over the USB cable to the Arduino.

The Arduino has its own sketch which reads the commands from the USB cable and interprets them to turn the respective LEDs on and off.

Although the USB cable can send data back from the Arduino to the computer, I’m not using that capability here.

Here’s the physical layout in my elaborately equipped and tidy laboratory:

And here’s a closeup of the Arduino and the poor suffering breadboard:

BTW, the LEDs and the jumpers came from the Getting Started with Arduino kit. I’m not sure if this breadboard or the one in the background came with the kit.

Anyway, here’s the raw video:

Although not shown in the video, I can turn on more than one LED at a time, but I’m not sure that’s good for the Arduino. Haven’t burned it out yet, though!

The next step in the project is to interface the Arduino with a remote controlled toy ‘stunt’ vehicle, which coincidently has four on/off inputs. My nephew (to whom I’m assigning the designation Engineer One) needs to come over and we’re going to take it slow because I don’t want to burn out the Arduino. Which as surely as rain falls and the sun rises . . . .

BTW, I notice the diodes I downloaded from Google Sketchup 3D Warehouse look really nice, but lack a couple package details that are typically found in real-world diodes and helpfully explain to newbie electronics hobbyists (such as moi) which side is which. Hence I modified like so:

Just remember to connect ‘flatter’ and ‘shorter’ toward ground, and you too can be confident that your circuit will burn out for some other reason.

About engineerzero

Once and future engineer.
This entry was posted in Uncategorized and tagged , , , , , , , , . Bookmark the permalink.

8 Responses to PC to Arduino to LED Control

  1. Ludovic Zamord says:

    Hi I’m a french student,
    And i’m having trouble doing this program. I’d like to know if you’d could help me a bit?
    If that’s possible, please send a mail, and I will reply to it with my questions.

  2. eswaryuva says:

    would you please send the processing sketch to me.

  3. Pingback: PC to Arduino to LED Control, Source Code | Engineer Zero

  4. Herro Salim says:

    Hi, I’m new to Arduino,
    I have downloaded the sketch for the processing and arduino. I run the sketches but nothing happen on the leds on arduino board, any suggest?
    The board is working other sketch.

    • engineerzero says:

      Are you copying and pasting the code directly? One problem that people have had in the past is using a ” (double quote) when they should use a ‘ (single quote) for char variables.

      I used a regular UNO for the program. Perhaps UNO R3 or Leonardo are different. You may want to check Arduino.cc site for changes that might affect serial communications.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s