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.
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.
Thanx
An e-mail has been sent.
would you please send the processing sketch to me.
eswar.yuvar@gmail.com
https://engineerzero.wordpress.com/2012/12/05/pc-to-arduino-to-led-control-source-code/
Pingback: PC to Arduino to LED Control, Source Code | Engineer Zero
In case anyone is interested, the source code for this project is at:
https://engineerzero.wordpress.com/2012/12/05/pc-to-arduino-to-led-control-source-code/
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.
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.