Computer Controlled Arduino




Introduction: Computer Controlled Arduino

About: I just love making stuff...and working out!

Have you ever wanted to control the Arduino with a program on your computer that can handle a full GUI? I'm sure most will say yes, but a full GUI takes hard work. You need to know the basics of it all before you can do the whole thing. A really good program that you can make a GUI with is Processing. You can get this at

The Arduino IDE is based off of the one from Processing. On the site you can look at the reference guide and tutorials to help you get used to processing if you need it. Processing allows us to make programs on the computer that can get input from the mouse and keyboard and through a serial port give that information to the Arduino. Let's

get started!

(I've entered this in the Coded Creations contest so please vote for me)

Step 1: Stuff Required


1. Arduino Uno (I used a Rev3)

2. Breadboard

3. 2 LEDs of two different colors

4. Jumper wires

5. 2 220Ohm Resistors

6.USB programming cable for Arduino Uno

7. Processing

8. Arduino IDE

9. A brain


1. Time

2. Blood, Sweat, and Orange Juice

Step 2: Make the Circuit

The circuit in the image is the circuit you will need.

It is a fairly simple circuit and it won't take too long to make it.

You just need to hook up the 2 LEDs to the Arduino through Digital I/O pins with 220Ohm resistors to ground.

Hook the ground from the Arduino to the ground line on your breadboard and you've finished the circuit.

Step 3: Make the Processing Program

First, you start with the Processing program. It is a basic program that takes input from the computer and gives you visual feedback along with writing to a serial port.

The program I wrote was...

Arduino LED Control By: RobotsWillRule 5/2/2015

Based off of representative colors for the LEDs. Processing control by keyboard. AS for LEDs. R for reset. **/

import processing.serial.*;

Serial port;

void setup(){

//Sets the size

size(300, 300);

//Sets the neutral background color



port = new Serial(this, 9600); }

void draw(){

//This reads to see if a key is pressed


//These If Statements check to see if a certain key is pressed

if(key == 'a' || key == 'A'){

//These backgrounds are the representative colors of the LEDs

background(50, 20, 200);

port.write('B'); // This writes to the serial port for the Arduino


if(key == 's' || key == 'S'){

background(0, 100, 0);

port.write('G'); }

//This is for the reset of the screen and LEDs on Arduino

if(key == 'r' || key == 'R'){


port.write('w'); } } }

All this program does is take input of A, S, or R on the computer then gives visual feedback on the computer in the form of background colors. After that it writes to a serial port through the Serial library so the Arduino can read it. A list of open COM ports are printed in the black box at the bottom of the IDE

Step 4: Make the Arduino Code

The code for the Arduino is for the LEDs and reading the serial port for commands. When it gets a command it lights up the correspondent LED. The following code is what I used, but I'm sure you and everyone else here can modify it in all sorts of ways. In fact I hope that everyone who reads this tries to modify every aspect of it. That is how you're supposed to learn right?

char ledRef;
int bLed = 11;

int gLed = 9;

void setup() {

pinMode(bLed, OUTPUT);

pinMode(gLed, OUTPUT);

Serial.begin(9600); }

void loop() {

if(Serial.available()) {

ledRef =;}

if(ledRef == 'B'){

digitalWrite(bLed, HIGH);}

if(ledRef == 'G'){

digitalWrite(gLed, HIGH);}


digitalWrite(bLed, LOW);

digitalWrite(gLed, LOW); }}

This Arduino code checks for commands over the serial port. If the right command is given for a certain LED it will light up. The code doesn't do anything special for codes without any meaning.

Step 5: Time for Testing

Now is the time to test if it will actually work together.

First, you need to upload the code to the Arduino.

If you don't do that the code won't upload right because the COM port would be active from the Processing sketch.

Then, you start the Processing application you made.

A small black screen will pop up.

Press the A key and it will turn blue.

If you did everything right the blue LED will light up.

Next, if you press the S key the green LED will light up along with the window turning green.

For both the LEDs to turn back off press the R key.

If all this works you made it right!

Step 6: Troubleshooting

1. Check your circuit. Although its low voltage unplug the Arduino and check to make sure the LEDs are in the right way and if the wires are in right.

2. Check your code. Coding problems are always there in some way or form. It is just the matter of finding them that makes it hard.

3. If you can't find the problem feel free to ask questions. I'm sure there is someone (like me) that won't mind helping.

Step 7: Thank You

This is my first Instructable, but I plan on making many more. Please give suggestions for this and/or other projects.(But please none that will break the bank!)

Coded Creations

Participated in the
Coded Creations

Be the First to Share


    • Puzzles Speed Challenge

      Puzzles Speed Challenge
    • "Can't Touch This" Family Contest

      "Can't Touch This" Family Contest
    • CNC Contest 2020

      CNC Contest 2020

    7 Discussions


    5 years ago on Introduction

    Got 3 Errors , in the first program

    1. Key wasn't declared

    2.Background wasn't declared in this scoupe

    3. port wasn't declared


    Reply 5 years ago on Introduction

    Make sure you didn't accidentally capitalize a letter or misspelled something. And if you copied straight from the 'ible you should actually go through and import the library instead of just typing it in. It might also cause problems if you're in a different mode than the Java one. If this doesn't help would it be possible for me to see the code you were using?


    Reply 5 years ago on Introduction

    Thanks! I've been on here for a while and thought I should finally start sharing stuff.